java.lang.ClassCastException: java.util.HashSet cannot be cast to org.hibernate.collection.spi.PersistentCollection

Hibernate JIRA | Alexander Pinske | 5 months ago
  1. 0

    The attached test case produces a ClassCastException when run (mvn test) with enhancement enabled. It runs fine without. {noformat} 2016-07-22 23:01:26,237 DEBUG org.hibernate.SQL - insert into Thing (id) values (null) 2016-07-22 23:01:26,261 DEBUG org.hibernate.SQL - insert into SomeEntity (id, lastChangedAt, parent_id, version) values (null, ?, ?, ?) Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4 sec <<< FAILURE! test(eu.pinske.test.ThingTest) Time elapsed: 3.782 sec <<< ERROR! java.lang.ClassCastException: java.util.HashSet cannot be cast to org.hibernate.collection.spi.PersistentCollection at org.hibernate.event.internal.FlushVisitor.processCollection(FlushVisitor.java:39) at org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:104) at org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:65) at org.hibernate.event.internal.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:59) at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:155) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:216) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:85) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:38) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1397) at eu.pinske.test.ThingTest.test(ThingTest.java:30) {noformat} The exception seems to only occur in these particular circumstances: * the entity uses a PreUpdate-hook * the entity has a Version-column * one collection is created before persist, another one after persist Unfortunately I was not able to narrow it down further.

    Hibernate JIRA | 5 months ago | Alexander Pinske
    java.lang.ClassCastException: java.util.HashSet cannot be cast to org.hibernate.collection.spi.PersistentCollection
  2. 0

    Hibernate exception java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.util.Date

    Stack Overflow | 3 years ago | Michal
    java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.util.Date
  3. 0

    Hibernate saveOnUpdate @Type gives classCastException for Object of StringType

    Stack Overflow | 9 months ago | s_riya
    java.lang.ClassCastException: com.apple.sfo.domain.ModifyFixtureBatchUpdateRequest cannot be cast to java.lang.String
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Uploading File-project-type with multiple chunks throws unhandled exception

    https://bugzilla.redhat.com/bugzilla/ | 2 years ago | Alex Eng
    java.lang.ClassCastException: org.hibernate.action.internal.EntityIdentityInsertAction cannot be cast to org.hibernate.action.internal.EntityInsertAction

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      java.util.HashSet cannot be cast to org.hibernate.collection.spi.PersistentCollection

      at org.hibernate.event.internal.FlushVisitor.processCollection()
    2. Hibernate
      SessionImpl.flush
      1. org.hibernate.event.internal.FlushVisitor.processCollection(FlushVisitor.java:39)
      2. org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:104)
      3. org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:65)
      4. org.hibernate.event.internal.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:59)
      5. org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:155)
      6. org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:216)
      7. org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:85)
      8. org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:38)
      9. org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1397)
      9 frames
    3. eu.pinske.test
      ThingTest.test
      1. eu.pinske.test.ThingTest.test(ThingTest.java:30)
      1 frame