hibernate.order_inserts create wrong order which ends with ConstraintViolationException

Description

Hello
I have folowing relation: Team has members + Team has optional relation to coach.
Member and Coach is the same class Person
https://github.com/MirekSz/HHH-12783.git

hibernate.order_inserts=true throws ConstraintViolationException because of wrong order of inserts, disabling hibernate.order_inserts=false and code works fine. In my opinion there is problem in algorithm of sorting because you don't look at optional attribute of relation

Environment

None

Status

Assignee

Unassigned

Reporter

Mirek

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

Components

Affects versions

5.2.17
5.1.15
5.3.2

Priority

Major