This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Reply 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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Can I say an entity manager injected into session bean must be container managed?
 
Similar Threads
Persitence confusion. Please help.
EJB3 Beta Certification - EntityManager BASIC notes.
Passed SCBCD 5.0 :)
Resource Local Transactions
EJB3 Beta Certification - Help =))