| 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. |