JPA persistence using multiple threads

前端 未结 2 1380
逝去的感伤
逝去的感伤 2021-01-07 04:11

I have a problem when I try to persist objects using multiple threads.

Details :

Suppose I have an object PaymentOrde

2条回答
  •  忘掉有多难
    2021-01-07 04:30

    Hibernate sessions are not thread-safe. JDBC connections that underlay Hibernate are not thread safe. Consider multithreading your business logic instead so that each thread would use it's own Hibernate session and JDBC connection. By using a thread pool you can further improve your code by adding ability of throttling the number of the simultaneous threads.

提交回复
热议问题