SessionImpl.flush() has thrown a ClassCastException

java.lang.ClassCastException
Javadoc
Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. For example, the following code generates a ClassCastException:
    Object x = new Integer(0);
    System.out.println((String)x);
@author unascribed @since JDK1.0
at org.hibernate.event.internal.FlushVisitor.processCollection
(source)
at org.hibernate.event.internal.AbstractVisitor.processValue
(source)
at org.hibernate.event.internal.AbstractVisitor.processValue
(source)
at org.hibernate.event.internal.AbstractVisitor.processEntityPropertyValues
(source)
at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity
(source)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities
(source)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions
(source)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush
(source)
at org.hibernate.internal.SessionImpl.flush
(source)
8 frames hidden

Typical Exception Messages

  1. java.util.LinkedHashSet cannot be cast to org.hibernate.collection.spi.PersistentCollection
  2. java.util.HashSet cannot be cast to org.hibernate.collection.spi.PersistentCollection
  3. Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction

Specific cases

External results for this pattern (2)

  1. Alexander Pinskevia Hibernate JIRA4 months ago
    java.util.HashSet cannot be cast to org.hibernate.collection.spi.PersistentCollection
    Show stack trace
  2. Petar Tahchievvia Spring JIRA2 years ago