aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Can I say an entity manager injected into session bean must be container managed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Can I say an entity manager injected into session bean must be container managed?" Watch "Can I say an entity manager injected into session bean must be container managed?" New topic
Author

Can I say an entity manager injected into session bean must be container managed?

Mellon Sun
Ranch Hand

Joined: Feb 20, 2003
Posts: 126
For application managed entity manager, a EntityManagerFactory should be injected and get the entity manager via EntityManagerFactory.createEntityManager().
For container managed entity manager, it can be directly injected into a session bean.

So, can I say if an entity manager is injected into a session bean, then it should be a container managed one, and a container managed entity manager should be a JTA entity manager, then an injected entity manager in EJB must be a JTA entity manager but never can be a resource-local one?


SCJP,SCWCD1.3,SCWCD1.4,SCJD,SCBCD5,SCEA5
LakshmiNarayana Kodali
Greenhorn

Joined: Oct 30, 2008
Posts: 16
Yes you are correct

If an EntityManager is injected into Session bean using DI, it is Container managed JTA Entity Manager. And Container Managed EntityManager cannot be resouce local EntityManager.


Application Managed EntityManagers can be created using EntitymanagerFactory but cannot be injected using DI.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I say an entity manager injected into session bean must be container managed?