-
1. Jndi name of persistence unit (persistence.xml)
iabughosh Jan 26, 2011 9:00 AM (in response to kudlaty15)Dear Riddick,
see these links
http://community.jboss.org/message/365135
http://docs.jboss.org/ejb3/docs/reference/build/reference/en/html/entityconfig.html
hope this will help
-
2. Jndi name of persistence unit (persistence.xml)
kudlaty15 Jan 27, 2011 3:09 PM (in response to iabughosh)I know that my post is a liitle to long, but please read carefully. I know that I can create global JNDI of my persistence unit by some properties in persistence.xml! Lookup on this jndi will return EntityManager or EntityManagerFactory(depends on property). I am using Hibernate and I must get SessionFactory (Hibernate). This cool integration :http://bill.burkecentral.com/2007/07/06/co-existence-with-hibernate-jpa-and-ejb3 can mix hibernate with jpa and ejb3 from JBOSS. This is very cool feature becouse Jboss create for U SessionFactory object and U can inject this object with nice annotation (@PersistenceUnit). Later I was trying Hibernate MBean in JBoss but this solution is not universal and it's slowly departs (for example there is a couple important properties that is not mapped to Jboss MBean Hibernate service). My question was about naming convention in Jboss. Server automatically bind SessionFactory described in persistence.xml but the name of jndi is unacceptable. Can i change name of this jndi ?
-
3. Re: Jndi name of persistence unit (persistence.xml)
jaikiran Jan 27, 2011 11:56 PM (in response to kudlaty15)Riddick Pu wrote:
I know that I can use properties like: <property name="jboss.entity.manager.jndi.name" value="java:/Manager1"/> ... in persistence.xml file to create global JNDI of my persistence unit. This solution is not satisfactory becouse the InitialContext.lookup returns EntityManager object while I want SessionFactory
You can do this:
EntityManager em = (EntityManager) initialCtx.lookup("java:/Manager1"); SessionFactory sessionFactory = em.unwrap(Session.class).getSessionFactory();
where Session and SessionFactory are from the appropriate Hibernate package.