DelayedPostInsertIdentifier EXCEPTION on flush of identity created PARENT that has sequence created CHILD with cascade, when batch_update is true

Description

There is problem, when parent entity has generated value IDENTITY and batch update is enabled.

This happens only (if all conditions are met):

  • parent has generated value IDENTITY (changing this to SEQUENCE fixes problem)
    - if parent entity has child list initialized on class instantialization
    and one parent is read from database, and the other is created in session and flushed
    than two child entities are created for each, and linked and flushed .
    - persisence factory property 'hibernate.order_updates' is set to true


LOG OF EXCEPTION

Error output of class: java.lang.ClassCastException:449895102
org.hibernate.action.internal.DelayedPostInsertIdentifier cannot be cast to java.lang.Long
Stack:
java.lang.Long.compareTo(Long.java:54)
org.hibernate.internal.util.compare.ComparableComparator.compare(ComparableComparator.java:23)
org.hibernate.internal.util.compare.ComparableComparator.compare(ComparableComparator.java:18)
org.hibernate.type.AbstractStandardBasicType.compare(AbstractStandardBasicType.java:215)
org.hibernate.action.internal.CollectionAction.compareTo(CollectionAction.java:159)
org.hibernate.engine.spi.ExecutableList.add(ExecutableList.java:227)
org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:307)
org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:371)
org.hibernate.event.internal.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:301)
org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:95)
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:38)
org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1454)
org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1440)

created data model for DB2 and testCase ORM5 are included in:

Environment

Hibernate libraries 5.3.6
JVM: 8 (181)
operating system: windows 7
database: IBM DB2 10.5

Status

Assignee

Chris Cranford

Reporter

Primož Vranešič

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.3.6

Affects versions

Priority

Major
Configure