@PersistenceContext EntityManager thread-safety in Spring and Java EE

前端 未结 1 1849
萌比男神i
萌比男神i 2020-12-31 06:41

EntityManager is not thread-safe by definition. Servlets specs says that in non-distributed environment and without implementing SingleTh

1条回答
  •  执念已碎
    2020-12-31 07:18

    Question 2, 3, and 4 -- Spring does not pay attention to any class that is not a Spring Bean. Therefor Spring does not pay attention to you MyServlet class. Therefore the answer for

    • 2) is no
    • 3) only Spring managed Beans
    • 4) it is Springs responsibility, because Spring is the Container

    For Question 1). It works this way, so the usage of an Spring Injected Entity Manager is effective thread save.

    0 讨论(0)
提交回复
热议问题