Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Injecting an EntityManager

 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When I want to inject an EntityManager, I use the PersistenceContext annotation with the name element that points to the JNDI entry name where the EntityManager is found.

Does this mean that the application deployer must create JNDI entries for the name provided by the annotation before the application starts. And what happens when the unitName is not specified???

Thanks in advance
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the EJB container takes care of creating the JNDI entries as a part of the Enterprise Naming Context for the bean.
Regarding your second query, if the persistent unit name is not specified, I think the default pesistent unit is assumed(which should be the only PU defined for the application). If more than one PU is defined the you get



and then it is mandatory to priovide unit name.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic