ClassCastException « EntityManager « JPA Q&A





1. Hibernate java.lang.ClassCastException: org.hibernate.action.EntityIdentityInsertAction cannot be cast to org.hibernate.action.EntityInsertAction    stackoverflow.com

I'm using Hibernate with an EntityManager. When I use

    Session session = (Session)entityManager.getDelegate();  
    session.flush();
    session.clear();
I get
java.lang.ClassCastException: org.hibernate.action.EntityIdentityInsertAction cannot ...