I read the section 2.3 of JBoss EJB 3.0 Reference Documentation:
Quote:
You can get access to the current underlying Hibernate Session by typecasting your reference to EntityManager.
@PersistenceContext EntityManager entityManager;
public void someMethod();
{
org.jboss.ejb3.entity.HibernateSession hs = (HibernateSession)entityManager;
org.hibernate.Session session = hs.getHibernateSession();
}
But, if I made a typecast to HibernateSession in my program, I get a ClassCastException, because my EntityManager is an instance of the class org.hibernate.ejb.EntityManagerImpl which cannot be casted to HibernateSession.
I use Hibernate 3.1 and EJB3.0RC5.