[jboss-jira] [JBoss JIRA] Commented: (AS7-218) hibernate fails to bind session factory name to jndi

Scott Marlow (JIRA) jira-events at lists.jboss.org
Thu Sep 1 13:41:27 EDT 2011


    [ https://issues.jboss.org/browse/AS7-218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625819#comment-12625819 ] 

Scott Marlow commented on AS7-218:
----------------------------------

The Hibernate SessionFactory can be used to get Sessions.  A possible workaround, would be to use JPA instead of the Hibernate API.  Then, "jboss.entity.manager.factory.jndi.name" could be used to specify the jndi name for the entity manager factory (which can be used to get EntityManager's (JPA equivalent of Hibernate Session).

Once you have the EntityManager, call the EntityManager.unwrap(Session.class) to get the Hibernate session class (if you still want it).  This is now supported in Hibernate 4.0.

Other JPA options (with Hibernate 4.0) would be to just inject from a @PersistenceUnit into a Hibernate SessionFactory variable (or @PersistenceContext into a Hibernate Session variable.)

> hibernate fails to bind session factory name to jndi
> ----------------------------------------------------
>
>                 Key: AS7-218
>                 URL: https://issues.jboss.org/browse/AS7-218
>             Project: Application Server 7
>          Issue Type: Bug
>          Components: JPA / Hibernate
>    Affects Versions: 7.0.0.Beta2
>            Reporter: George Sapountzis
>            Assignee: Scott Marlow
>             Fix For: 7.1.0.Beta1
>
>
> Put the following line in persistence.xml:
> <property name="hibernate.session_factory_name" value="modelSessionFactory" />
> Hibernate fails to bind modelSessionFactory.
> Remove the following two lines from HibernatePersistenceProviderAdaptor.java
> -        properties.put("hibernate.jndi.java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
> -        properties.put("hibernate.jndi.java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
> Then the bindind succeeds.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list