JAVA: an EntityManager object in a multithread environment

后端 未结 5 1139
傲寒
傲寒 2020-12-07 16:50

if I have multiple threads, each use injector to get the EntityManager object, each use the em object to select a list of other class objects. Ready to be used in a for loop

5条回答
  •  一向
    一向 (楼主)
    2020-12-07 17:36

    You normally have transactions around what you do with database objects. What each given thread sees about the changes made by other threads is controlled by 'transaction isolation' settings.

    Start learning about different isolation settings and apply the right setting according to your needs. There is a trade-off between accuracy and speed. http://en.wikipedia.org/wiki/Isolation_%28database_systems%29

提交回复
热议问题