It seems that Embedded classes are not being taken into account when batch insert statements are ordered.
In the test case for example, when the insert statements are ordered (org.hibernate.engine.ActionQueue.sortInsertActions), the "state" of the Car EntityInsertAction is the (Embedded)Registration object, but the checkAction instance ,that should be indicating that there is a FK dependency, is of course, Driver. So the Car insert, which has a FK to the Driver insert, is ordered to execute before the Driver insert.
, I'm still willing to work with your pull request, but can you please give us the test case that you were using to reproduce?
Closing this, for now. On master (4.3.0-SNAPSHOT), I'm not able to reproduce. (or anyone), if there's a newer test case that proves otherwise, please attach and mention it.
i found this problem too, but it only happens when:
-IDENTITY is the generation strategy.
-order_inserts is set to true.
Whenever order_inserts is set to false, or the strategy is for example SEQUENCE, it shall not be reproduceable (in my case, when we changed from a PostgreSQL DB to a MS SQLServer with GenerationType.AUTO)
I hope it helps to solve the issue.
, have a test case we could use to reproduce?
Closing this, for now. The ActionQueue was recently revamped (4.3.0) and included fixes similar to 's original pull request. Judging by the stacktraces, this should no longer be an issue.
I verified that the original test case works w/ hibernate.order_inserts=true and IDENTITY id generation. Please try this again on 4.3.0.Beta5 when it's out later today.