5 Replies Latest reply on Aug 12, 2009 10:57 AM by Adam Warski

    Envers 1.1.0 G.A and Hibernate 3.2

    Ganesh Sethuraman Newbie

      Hi Adam,
      We were trying Envers 1.1.0 G.A with hibernate 3.2.4. We got the following error when persisting a parent child relationship

      org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.dnb.cp.core.model.Entity_AUD#{VER_REV=com.dnb.cp.core.model.CpRevisionEntity@95d502, entityId=22}]
      at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:168)
      at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
      at org.hibernate.ejb.event.EJB3SaveEventListener.saveWithGeneratedId(EJB3SaveEventListener.java:43)
      at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
      at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
      at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
      at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
      at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
      at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
      at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
      at org.jboss.envers.synchronization.work.CollectionChangeWorkUnit.perform(CollectionChangeWorkUnit.java:54)
      at org.jboss.envers.synchronization.VersionsSync.executeInSession(VersionsSync.java:120)
      at org.jboss.envers.synchronization.VersionsSync.beforeCompletion(VersionsSync.java:144)
      at org.hibernate.transaction.JDBCTransaction.notifyLocalSynchsBeforeTransactionCompletion(JDBCTransaction.java:228)
      at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:109)
      at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
      at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:456)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:732)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:701)
      at org.springframework.test.AbstractTransactionalSpringContextTests.endTransaction(AbstractTransactionalSpringContextTests.java:355)
      at org.springframework.test.AbstractTransactionalSpringContextTests.onTearDown(AbstractTransactionalSpringContextTests.java:287)
      at org.springframework.test.AbstractSingleSpringContextTests.tearDown(AbstractSingleSpringContextTests.java:137)
      at junit.framework.TestCase.runBare(TestCase.java:140)
      at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
      at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001(AbstractAnnotationAwareTransactionalTests.java:71)
      at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1.run(AbstractAnnotationAwareTransactionalTests.java:175)
      at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTest(AbstractAnnotationAwareTransactionalTests.java:283)
      at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTestTimed(AbstractAnnotationAwareTransactionalTests.java:254)
      at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runBare(AbstractAnnotationAwareTransactionalTests.java:172)
      at org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:174)
      at org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:255)
      at junit.framework.TestResult$1.protect(TestResult.java:110)
      at junit.framework.TestResult.runProtected(TestResult.java:128)
      at junit.framework.TestResult.run(TestResult.java:113)
      at junit.framework.TestCase.run(TestCase.java:124)
      at junit.framework.TestSuite.runTest(TestSuite.java:232)
      at junit.framework.TestSuite.run(TestSuite.java:227)
      at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
      at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
      at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)

      But after settingorg.jboss.envers.revisionOnCollectionChange to "false" the error was removed. I understand that if the above property is set and if collection(mappedBy) changes the mappedBy side wont have an audit record in the audit table. is there a fix in the envers code for the same?
      What are the disadvantages of setting that property to false?