How does the UserTransaction and the EntityManager interact?

后端 未结 1 423
失恋的感觉
失恋的感觉 2021-02-02 15:30

This is an academic question; I have no broken code in relation to this. I just want to expand my understanding of what is happening under the hood.

The code pattern I

相关标签:
1条回答
  • 2021-02-02 15:50
    1. Because UserTransaction is part of Java Transaction API (JTA) and EntityManager is part of Java Persistence API (JPA). JTA is not part of JPA. JPA uses services provided by JTA.

    2. Isn't ManagedProperty is some annotation which is valid only in classes annotated with @ManagedBean. Maybe it was considered better to not inject UserTransaction different way in managed beans.

    3. JNDI lookup for active transaction. Reserved name seems to be java:comp/UserTransaction. One implementation: http://www.java2s.com/Open-Source/Java-Document/Database-ORM/hibernate/org/hibernate/transaction/JTATransactionFactory.java.htm

    4. It is not some sort of singleton, you can have more than one. But only one per thread can be active.

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