« Return to Thread: PersistenceContext and Hibernate session

Re: PersistenceContext and Hibernate session

by chawax :: Rate this Message:

Reply to Author | View in Thread

Yes, Hibernate is not part of JPA (even though JPA is based on concepts created by Hibernate). But it can be used as a JPA implementation, then it adds features to JPA ones (criterias for example).
I think my problem is that org.hibernate.Session does not implement javax.persistence.EntityManager, so it looks like OpenEJB is right when it throws an error about this ;)

I found there's a org.hibernate.ejb.HibernateEntityManager that implements javax.persistence.EntityManager, I think I should use this one instead of org.hibernate.Session. I'm going to test this.

Martin Vysny-2 wrote:
On Fri, 2008-07-11 at 06:50 -0700, chawax wrote:
> Hi,
>
> In my application, I have two persistence contexts for the same persistence
> unit, one for JPA, the other for Hibernate :
>
>     /**
>      * Inject persistence context t4Seam    
>      */
>     @javax.persistence.PersistenceContext(unitName = "t4Seam")    
>     protected javax.persistence.EntityManager emanager;
>
>     /**
>      * Inject Hibernate Session
>      */
>     @javax.persistence.PersistenceContext(unitName = "t4Seam")    
>     protected org.hibernate.Session hibernateSession;
>
> It used to work with JBoss. But with OpenEJB, I have the following error:
> "Use of @PersistenceContext only applies to EntityManager references"
>
> Is it intented or is it a bug ?
>
> Olivier

I think it's intended: Hibernate API is not part of JPA/EJB3
specification afaik.

Martin

 

 « Return to Thread: PersistenceContext and Hibernate session

LightInTheBox - Buy quality products at wholesale price!