Hello Danilov Roman, thank you for reporting the issue and providing a reproducer. The error is caused by the @Generated property in the Interpretation entity: to be able to retrieve insert-generated values correctly Hibernate has to disable batching for entities having that annotation. This causes the order of operations to be changed: instead of inserting InterpretationData first, that gets added to the batch queue whereas the Interpretation insert is executed immediately, causing the foreign key error. You will have to either manually flush when inserting the parent entity or handle inserts in different transactions. |