Our Domain Model worked without any problems since years with hibernate 3. With hibernate 5.2.17 the problem arises only if order_inserts is true. With hibernate 5.2.4 the same test was green, even with activated order_inserts. In the log output of the test I see, that the OneToMany association is mapped by a join table, for which the insert statement is executed late. If we add @joincolumn to the OneToMany List the association is mapped by a join column in the child table. If with this changed mapping the same child object is added to the OneToOne and at the same time to the OneToMany association there in theory a "Chicken or the Egg" problem could arrise. In reality a test showed me, that hibernate in that situation executes two insert statements an an additional update statement to avoid that problem. But in our test case there is no @joincolumn and additionally we never add the same child object to the OneToOne and to the OneToMany association. In our application with thousands of entities we have a lot of constraint violations if we switch on order_inserts. With hibernate 3 this problem does'nt exist. What can we do? |