• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

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

Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Evil is afoot. But this tiny ad is just an ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic