Deleting entities is not happening in the right order. According to documentation: _all entity deletions shall happen in the same order the corresponding objects were deleted using Session.delete()_
When property, _hibernate.jdbc.batch_size = 20_, hibernate is using BatchingBatch, which at line 86, decides whether the statements shall be executed or not: _if ( batchPosition == batchSize ) {...}_
*Given* FOO and BAR entities both with InheritanceType.JOINED and FOO having a ManyToOne relation to BAR
*When* The following two lines are executed: entityManager.remove(foo); entityManager.remove(bar);
*Then* Hibernate doesn't execute the statement to remove FOO, but later It does execute the statement to remove BAR And as a result: _delete from BAR where id=2_ *throws* _Referential integrity constraint violation: "FKJFU6P0IRDHEYXGG5UDT0EAJAH: PUBLIC.FOO FOREIGN KEY(BAR_ID) REFERENCES PUBLIC.BAR(ID) (2)";_
Please check the attached test application. Just run _mvn install_.
|
|