FK violation in ValidityAuditStrategy when when flush mode is COMMIT
Description
After changing flush mode from auto to commit, I now get a foreign key constraint violation when an existing entity was modified. It looks like ValidityAuditStrategy.perform() is not flushing the session when flush mode is set to commit. Therefore the revision entity is not present in the database when ValidityAuditStrategy tries to update REVEND.
I was not able to get the changes to apply cleanly to the 4.2 branch. But I applied to master and 4.3 branches. Thanks for working on this Lukasz.
Olivier SambourgJuly 31, 2013 at 12:15 PM
Edited
Same issue here, using Hibernate 4.2.0 and Spring Webflow 2 with Websphere 8 (using WebSphereExtendedJtaPlatform) Webflow forces the FlushMode to MANUAL for non-transactional operations (as expected) and ValidityAuditStrategy sends an AutoFlush event prior to updating the previous RevisionEntity. The AutoFlush is ignored and no flush is performed, hence the FK constraint violation as the new RevisionEntity has not been inserted.
Using Tomcat (no JTA) the problem does not occur though.
After changing flush mode from auto to commit, I now get a foreign key constraint violation when an existing entity was modified.
It looks like ValidityAuditStrategy.perform() is not flushing the session when flush mode is set to commit. Therefore the revision entity is not present in the database when ValidityAuditStrategy tries to update REVEND.