Hibernate java.lang.ClassCastException: org.hibernate.action.EntityIdentityInsertAction cannot be passed to org.hibernate.action.EntityInsertAction

I am using Hibernate with EntityManager. When i use

    Session session = (Session)entityManager.getDelegate();  
    session.flush();
    session.clear();

I get

java.lang.ClassCastException: org.hibernate.action.EntityIdentityInsertAction cannot be cast to org.hibernate.action.EntityInsertAction
at org.hibernate.engine.ActionQueue$InsertActionSorter.sort(ActionQueue.java:636)
at org.hibernate.engine.ActionQueue.sortInsertActions(ActionQueue.java:369)
at org.hibernate.engine.ActionQueue.sortActions(ActionQueue.java:355)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:224)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)

Since it does not say which object is causing the problem, I am stuck here. Does anyone have an idea what might cause this?

+5
source share
1 answer

This is a bug in sleep mode. An exception occurs when the following conditions are true:

  • Id generation strategy identity
  • the object is stored outside the transaction
  • hibernate.order_inserts true

, EntityIdentityInsertAction ActionQueue.insertions, ActionQueue$InsertActionSorter , EntityInsertAction s.

, , .

, hibernate.order_inserts .

+2

All Articles