aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Injecting an EntityManager 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 "Injecting an EntityManager" Watch "Injecting an EntityManager" New topic
Author

Injecting an EntityManager

Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
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


SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
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.


Thanks and Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Injecting an EntityManager
 
Similar Threads
One of more persistence context for separate projects?
Question about the JNDI naming rules
How to inject EntityManager via setter in spring
Passivation Question
Passing EntityManager reference between methods doesn't work as expected