| From your PR, the problem is not the ordering, but your mapping. The Parent also has a FK to a Child:
@OneToOne(cascade = CascadeType.ALL)
public Child child;
which means the Child needs to exist prior to the Parent. So, the Child entity is the parent of the Parent entity. And, at the same time, the Parent is also a parent to the Child:
@OneToMany
private List<Child> otherChilds = new ArrayList<Child>();
This is a "Chicken or the Egg" problem and no sorting algorithm will figure out which one should be the first. Looking forward to your explanation about your Domain Model. |