Java Reference
In-Depth Information
Figure 10.5 puts the relationship among the EntityManagerFactory , EntityMan-
ager , EntityTransaction , and Entity into context. We haven't discussed an
EntityTransaction —it provides an API for fine-grained transaction management
when you aren't delegating to the container.
Figure 10.5. Relationships among the important JPA interfaces/ classes when using an application-managed
EntityManager
As you can see in the listing, the EntityManagerFactory has a cre-
ateEntityManager method for creating an application-managed EntityManager .
Once you have a reference to an application-managed EntityManager , it's your re-
sponsibility to destroy it when you are finished; otherwise bad things can happen.
One thing to learn from this listing is that an application-managed EntityManager
doesn't automatically participate in transaction management. Thus, you must use the
 
Search WWH ::




Custom Search