Page 88 of the Java Persistence with Hibernate book states the following code :
Code:
Session session = (Session) entityManager.getDelegate()
However, this throws a ClassCastException at runtime because the returned object is of type org.hibernate.ejb.EntityManagerImpl
I therefore think the code example should be changed to
Code:
Session session = ((HibernateEntityManager) entityManager.getDelegate()).getSession();
or
Code:
HibernateEntityManager hibernateEntityManager = (HibernateEntityManager) entityManager.getDelegate();