With Infinispan remote dialect, a large cascade delete on a bidirectional association and a subsequent flush could bring persistence context in an inconsistent state, causing in turn this error on commit operation:
`javax.persistence.RollbackException: Error while committing the transaction
at org.hibernate.ogm.backendtck.inheritance.singletable.family.SingleTableInheritancePersistTest.testFlushAndCommitAfterCascadeDelete(SingleTableInheritancePersistTest.java:192)
Caused by: java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : org.hibernate.ogm.backendtck.inheritance.singletable.family.Woman.familyName -> org.hibernate.ogm.backendtck.inheritance.singletable.family.Family
at org.hibernate.ogm.backendtck.inheritance.singletable.family.SingleTableInheritancePersistTest.testFlushAndCommitAfterCascadeDelete(SingleTableInheritancePersistTest.java:192)
Caused by: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : org.hibernate.ogm.backendtck.inheritance.singletable.family.Woman.familyName -> org.hibernate.ogm.backendtck.inheritance.singletable.family.Family
`
Test case is here:
There would be two possibilities here:
Forcing flush of the previous operations on batch, just before to traverse association to a deleted entity
Even better, skip the check if the operation queue contains the remove operation of referenced entity
I've implemented the latter. In my opinion, forcing flush should be considered the last option.