Uploaded image for project: 'Hibernate ORM'
  1. HHH-8243

FK violation in ValidityAuditStrategy when when flush mode is COMMIT

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.2.1
    • Fix Version/s: 4.3.2
    • Component/s: hibernate-envers
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      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.

      com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException
      Cannot add or update a child row: a foreign key constraint fails (`pim`.`pim_feature_groups_AUD`, CONSTRAINT `FK_d82a6ca0ceda4dd5a2f2f49a41a` FOREIGN KEY (`REVEND`) REFERENCES `custom_revisions` (`id`))
      
      java.lang.reflect.Constructor.newInstance(Constructor.java:532) 
       com.mysql.jdbc.Util.handleNewInstance(Util.java:411) 
       com.mysql.jdbc.Util.getInstance(Util.java:386) 
       com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1041) 
       com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120) 
       com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052) 
       com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503) 
       com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664) 
       com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815) 
       com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155) 
       com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458) 
       com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375) 
       com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359) 
       org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) 
       org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) 
       org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:133) 
       org.hibernate.envers.strategy.ValidityAuditStrategy$1.execute(ValidityAuditStrategy.java:200) 
       org.hibernate.envers.strategy.ValidityAuditStrategy$1.execute(ValidityAuditStrategy.java:162) 
       org.hibernate.jdbc.WorkExecutor.executeReturningWork(WorkExecutor.java:72) 
       org.hibernate.internal.SessionImpl$3.accept(SessionImpl.java:1993) 
       org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.coordinateWork(JdbcCoordinatorImpl.java:284) 
       org.hibernate.internal.SessionImpl.doWork(SessionImpl.java:2000) 
       org.hibernate.internal.SessionImpl.doReturningWork(SessionImpl.java:1996) 
       org.hibernate.envers.strategy.ValidityAuditStrategy.perform(ValidityAuditStrategy.java:161) 
       org.hibernate.envers.synchronization.work.AbstractAuditWorkUnit.perform(AbstractAuditWorkUnit.java:76) 
       org.hibernate.envers.synchronization.AuditProcess.executeInSession(AuditProcess.java:116) 
       org.hibernate.envers.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:155) 
       org.hibernate.envers.synchronization.AuditProcessManager$1.doBeforeTransactionCompletion(AuditProcessManager.java:62) 
       org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:666) 
       org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:309) 
       org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:613) 
       org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:105) 
       org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
      

        Attachments

          Issue links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: