-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Jndi name of persistence unit (persistence.xml)
PostPosted: Mon Jan 24, 2011 4:58 am 
Newbie

Joined: Mon Jan 24, 2011 3:22 am
Posts: 2
I am using Jboss EJB3/JPA integration to get Hibernate SessionFactory object defined in persistence.xml. I am able to inject SessionFactory to EJB by annotation @PersistenceUnit. But I have to use SessionFactory in one servlet. Here the problems begin. Injection to servlet not working and I cannot use spring injection becouse of the application architecture. Then in jboss logs I saw that automatically server bind SessionFactory described in persistence.xml to JNDI. So I can get SessionFactory object by InitialContext.lookup() and it's work. The problem is in name of the JNDI. Jboss automatically assign unacceptable and ugly name like: INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.unit:unitName=my_application.ear/my_application-service-1.1.2-JBOSS-SNAPSHOT.jar#hibernateUnitMyApplication. The name is very long and contains for example name and versions of jar and more unnecessary information. The question is HOW I CAN CHANGE THIS NAME? I know that I can use properties like: <property name="jboss.entity.manager.jndi.name" value="java:/Manager1"/> or <property name="jboss.entity.manager.factory.jndi.name" value="java:/Manager1Factory"/> 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:( Please help:)
On this website You can read about cool Jboss EJB/JPA integration - http://bill.burkecentral.com/2007/07/06/co-existence-with-hibernate-jpa-and-ejb3


Top
 Profile  
 
 Post subject: Re: Jndi name of persistence unit (persistence.xml)
PostPosted: Mon Jan 24, 2011 5:10 am 
Newbie

Joined: Mon Jan 24, 2011 3:22 am
Posts: 2
Correction - I have to use SessionFactory object in POJO:) That POJO class use servlet so getting SessionFactory can be "done at two levels" - servlet or pojo.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.