aspose file tools*
The moose likes Object Relational Mapping and the fly likes JBoss returns SessionFactoryImpl if we retrieve Persistence Unit though JNDI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JBoss returns SessionFactoryImpl if we retrieve Persistence Unit though JNDI" Watch "JBoss returns SessionFactoryImpl if we retrieve Persistence Unit though JNDI" New topic
Author

JBoss returns SessionFactoryImpl if we retrieve Persistence Unit though JNDI

Nitin Bhardwaj
Ranch Hand

Joined: Feb 02, 2007
Posts: 72
Hi Friends,

I deployed a persistence unit and the JBoss 6 server logs show that it has been successfully deployed and bound to JNDI with name: "persistence.unit:unitName=XCMS.war#XCMSPU". I've checked this also by visiting JMX-Console of JBoss viewing JNDI tree over there. I tried to lookup this persistence unit object through JNDI using the code:



The output returned is:
Nitin, The class of retrieved object is=org.hibernate.impl.SessionFactoryImpl
This could be because JBoss uses Hibernate as Persistence Provider (and I've also defined the same in persistence.xml). I was expecting this object to be of type javax.persistence.EntityManagerFactory.
Is there any way by which I can retrieve EntityManagerFactory using JNDI?

I know that by following code the container can inject the EntityManager:


However, I just want to get hold of EntityManagerFactory through JNDI. What should I do?

Best Regards,
Nitin
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JBoss returns SessionFactoryImpl if we retrieve Persistence Unit though JNDI