"order_inserts = true" causes FK Violation when inserting Self Referential Entity with Single_Table Inherited Entities

Description

In a particular case as described below, order-inserts = true causes FK Violation, while order-inserts = false does not:

  1. A (a self-referential Entity) is inherited by both B and C using Single_Table inheritance strategy.

  2. We have created entites as so: C1 -> B1 -> C2 -> A1, where C1, C2, B1 and A1 are entities of types C,C,B and A respectively.

  3. When persisting C1, an FK Violation is thrown.

  4. In attached testcases

  1. , it is also observed that the order of inserts of some entities referred to by A,B or C gets ruined and causes FK violations different from observed with above case.

Above cases work just fine for order-inserts = false.
Both above cases are included in the attached test cases. Is this a limitation of the order_inserts feature, a bug or am I missing an accepted workaround?

Edit: Was reported in 5.2.8.final, tested in 5.2.17, 5.3.1 and 5.3.7 and same test cases failed in all versions.
Failing test cases are:
Tests in error:
InsertSortingTest1(org.hibernate.bugs.JPAUnitTestCase): Error while committing the transaction
InsertSortingTest3(org.hibernate.bugs.JPAUnitTestCase): Error while committing the transaction
InsertSortingTest6(org.hibernate.bugs.JPAUnitTestCase): Error while committing the transaction
InsertSortingTest9(org.hibernate.bugs.JPAUnitTestCase): Error while committing the transaction

Environment

None

Assignee

Vlad Mihalcea

Reporter

Akarsh Jain

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure