Hi,
I'm using Spring 2.0rc1 with JPA (Hibernate impl). The EntityManager is injected using the @PersistenceContext annotation in my service layer:
@PersistenceContext
private EntityManager em;
In some methods I have to use the Criteria API, so I need a reference to the current Hibernate Session. My idea was to downcast:
Session sess = ((HibernateEntityManager) em).getSession();
but this results in a ClassCastException:
java.lang.ClassCastException: $Proxy23
Any ideas how to get a reference to the underlying Session using the (very cool!) @PersistenceContext-approach?
Thank you,
Sebastian


Reply With Quote