-
1. Re: Hibernate JNDI binding
jaikiran Jul 11, 2011 6:49 AM (in response to prasad.deshpande)It's the server which is responsible for binding that to JNDI. Is there any specific reason why your code is trying to bind it?
-
2. Re: Hibernate JNDI binding
prasad.deshpande Jul 11, 2011 6:55 AM (in response to jaikiran)It's not my code which is binding it.. All I'm doing is
pp.setProperty( "hibernate.session_factory_name", jndiName);
& then
sessionFactory = config.buildSessionFactory();
After, config.buildSessionFactory(), it throws exception saying JNDI is readonly.
To give you background, I'm setting properties programatically & then calling this buildSessionFactory(). This all is being done in a servlet. If that's piece of info is any useful to you
-
3. Re: Hibernate JNDI binding
jaikiran Jul 11, 2011 7:35 AM (in response to prasad.deshpande)Okay, I now get your reference to https://issues.jboss.org/browse/AS7-421. Yeah, so it looks like this won't work in 7.0. Will have to wait for a future release.
-
4. Re: Hibernate JNDI binding
smarlow Jul 11, 2011 8:00 AM (in response to jaikiran)Note that AS7-421 + AS7-421 have zero votes. Please vote for issues that are important to you.
-
5. Re: Hibernate JNDI binding
prasad.deshpande Jul 11, 2011 9:35 AM (in response to smarlow)Any way to bind sessionfactory to JNDI... no..?? at all??
-
6. Re: Hibernate JNDI binding
jaikiran Jul 11, 2011 12:52 PM (in response to prasad.deshpande)You mean, if you are building the Hibernate session factory yourself? I don't think there's a way to get past this issue in such scenario. But Scott will know better.
-
7. Re: Hibernate JNDI binding
swd847 Jul 11, 2011 7:55 PM (in response to prasad.deshpande)If you let the container build the EntityManagerFactory for you then the JNDI binding will work, is there any particular reason you need to build it yourself?
-
8. Re: Hibernate JNDI binding
prasad.deshpande Jul 12, 2011 4:13 AM (in response to swd847)It's a legacy application which uses old style hibernate with setting properties programatically & binding sessionfactory to JNDI & then later retrieve sessionfactory to perform query/save on objects.
I know that this all can be done by creating different persistent unit (apart from the one used for entity beans) cause both uses different properties. However if I have to migrate it to use JPA, then changes are large. Since this application is portable across other app servers as well like weblogic & glassfish (& also jboss 5.1) with it's current running state, it's hard for me to justify this change to my management.
Also, as a quick test, I did try to create another persistent unit in same persistence.xml just for this part of application, but it gave me lot of problems with entity beans (I'm going to report that to Scott but I still need to know more details of the problem to even report.).
Btw, just out of curiosity, when you say letting container build EntityManagerFactory, do you mean by defining persistent unit & may be injecting sessionfactory/session into corresponding places?
-
9. Re: Hibernate JNDI binding
smarlow Jul 12, 2011 7:54 AM (in response to prasad.deshpande)From discussion on (#jboss-as7) IRC yesterday, a few ideas for fixing "hibernate.session_factory_name" support were discussed and will be worked on. One possibilty is to have a special JNDI location that is updateable (e.g. something under "java:jboss/"). Look for this as a post AS 7.0 change.
Another alternative but less useful (IMO), would be to have the (JPA) container handle the binding on behalf of Hibernate. This would be less than ideal, since native Hibernate (non-JPA) apps do not have an EE container available to handle this.