java.lang.ClassCastException: org.hibernate.action.internal.DelayedPostInsertIdentifier cannot be cast to java.lang.Long

Hibernate JIRA | Stig Runar Vangen | 2 years ago
  1. 0

    When bulk inserting entities, you might get an error similar to this: {quote} Exception in thread "main" java.lang.ClassCastException: org.hibernate.action.internal.DelayedPostInsertIdentifier cannot be cast to java.lang.Long at java.lang.Long.compareTo(Long.java:54) at org.hibernate.internal.util.compare.ComparableComparator.compare(ComparableComparator.java:41) at org.hibernate.internal.util.compare.ComparableComparator.compare(ComparableComparator.java:36) at org.hibernate.type.AbstractStandardBasicType.compare(AbstractStandardBasicType.java:225) at org.hibernate.action.internal.CollectionAction.compareTo(CollectionAction.java:172) at org.hibernate.engine.spi.ExecutableList.add(ExecutableList.java:222) at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:250) at org.hibernate.event.internal.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:274) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:103) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222) {quote} This is better illustrated in the attached sample application. This is the main logics causing problems: {code:java} for (int i = 0; i < 10000; i++) { final Entity1 entity1 = new Entity1(); session.persist(entity1); final Entity2 entity2 = new Entity2(); session.persist(entity2); // session.flush(); final Criteria criteria = session.createCriteria(Entity2.class); entity1.setEntities(criteria.list()); if (i % BULK_SIZE == 0) { session.flush(); } } {code} If you uncomment the first flush operation, it will work, but at a highly reduced performance level. If you comment out the collection setter, you'll see that the application finishes successfully in a few seconds.

    Hibernate JIRA | 2 years ago | Stig Runar Vangen
    java.lang.ClassCastException: org.hibernate.action.internal.DelayedPostInsertIdentifier cannot be cast to java.lang.Long
  2. 0

    When bulk inserting entities, you might get an error similar to this: {quote} Exception in thread "main" java.lang.ClassCastException: org.hibernate.action.internal.DelayedPostInsertIdentifier cannot be cast to java.lang.Long at java.lang.Long.compareTo(Long.java:54) at org.hibernate.internal.util.compare.ComparableComparator.compare(ComparableComparator.java:41) at org.hibernate.internal.util.compare.ComparableComparator.compare(ComparableComparator.java:36) at org.hibernate.type.AbstractStandardBasicType.compare(AbstractStandardBasicType.java:225) at org.hibernate.action.internal.CollectionAction.compareTo(CollectionAction.java:172) at org.hibernate.engine.spi.ExecutableList.add(ExecutableList.java:222) at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:250) at org.hibernate.event.internal.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:274) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:103) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222) {quote} This is better illustrated in the attached sample application. This is the main logics causing problems: {code:java} for (int i = 0; i < 10000; i++) { final Entity1 entity1 = new Entity1(); session.persist(entity1); final Entity2 entity2 = new Entity2(); session.persist(entity2); // session.flush(); final Criteria criteria = session.createCriteria(Entity2.class); entity1.setEntities(criteria.list()); if (i % BULK_SIZE == 0) { session.flush(); } } {code} If you uncomment the first flush operation, it will work, but at a highly reduced performance level. If you comment out the collection setter, you'll see that the application finishes successfully in a few seconds.

    Hibernate JIRA | 2 years ago | Stig Runar Vangen
    java.lang.ClassCastException: org.hibernate.action.internal.DelayedPostInsertIdentifier cannot be cast to java.lang.Long
  3. 0

    Strange cast error in Pig/Hadoop

    Stack Overflow | 3 years ago | Giovanni Botta
    java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    java.lang.Integer to java.lang.Long in Bincond

    pig-user | 2 years ago | Gufran Mohammed Pathan
    org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1066: Unable to open iterator for alias E. Backend error : Exception while executing [POBinCond (Name: POBinCond[chararray] - scope-298 Operator Key: scope-298) children: [[LessThanExpr (Name: Less Than[boolean] - scope-295 Operator Key: scope-295) children: [[POProject (Name: Project[int][0] - scope-293 Operator Key: scope-293) children: null at []], [ConstantExpression (Name: Constant(10) - scope-294 Operator Key: scope-294) children: null at []]] at []], [ConstantExpression (Name: Constant(less than 20) - scope-296 Operator Key: scope-296) children: null at []], [ConstantExpression (Name: Constant(More than or equal to 20) - scope-297 Operator Key: scope-297) children: null at []]] at []]: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
  6. 0

    java.lang.Integer to java.lang.Long in Bincond

    pig-user | 2 years ago | Gufran Mohammed Pathan
    org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1066: Unable to open iterator for alias E. Backend error : Exception while executing [POBinCond (Name: POBinCond[chararray] - scope-298 Operator Key: scope-298) children: [[LessThanExpr (Name: Less Than[boolean] - scope-295 Operator Key: scope-295) children: [[POProject (Name: Project[int][0] - scope-293 Operator Key: scope-293) children: null at []], [ConstantExpression (Name: Constant(10) - scope-294 Operator Key: scope-294) children: null at []]] at []], [ConstantExpression (Name: Constant(less than 20) - scope-296 Operator Key: scope-296) children: null at []], [ConstantExpression (Name: Constant(More than or equal to 20) - scope-297 Operator Key: scope-297) children: null at []]] at []]: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long

    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

      org.hibernate.action.internal.DelayedPostInsertIdentifier cannot be cast to java.lang.Long

      at java.lang.Long.compareTo()
    2. Java RT
      Long.compareTo
      1. java.lang.Long.compareTo(Long.java:54)
      1 frame
    3. Hibernate
      SessionImpl.flush
      1. org.hibernate.internal.util.compare.ComparableComparator.compare(ComparableComparator.java:41)
      2. org.hibernate.internal.util.compare.ComparableComparator.compare(ComparableComparator.java:36)
      3. org.hibernate.type.AbstractStandardBasicType.compare(AbstractStandardBasicType.java:225)
      4. org.hibernate.action.internal.CollectionAction.compareTo(CollectionAction.java:172)
      5. org.hibernate.engine.spi.ExecutableList.add(ExecutableList.java:222)
      6. org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:250)
      7. org.hibernate.event.internal.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:274)
      8. org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:103)
      9. org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55)
      10. org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222)
      10 frames