| Your entity mapping defines a circular dependency between SaleDocument and SaleDocuemntItem which causes this issue:
Well, that's just wrong because you can't delete a Child row because it might be referenced by a Parent and you can't delete the Parent row either because it's referenced by a Child. So, due to the circular dependency, the inserts can not follow a parent-child ordering. You can only do that with manual flushing, but that's not possible to automate in Hibernate, and neither we should ever do that because the entity model is flawed. So, you should never have such circular dependencies. Only SaleDocuemntItem should have a @ManyToOne association to SaleDocument while SaleDocument should use @JoinForumla as explained in this article. |