0 Replies Latest reply on Mar 19, 2014 10:47 AM by Yves Caloz

    _aud table was not being filled with anything

    Yves Caloz Newbie

      Hi,

      I have a problem with envers that _aud table was not being filled with anything.

       

      Infrastructure :

      • JBoss 5.1.0
      • Spring 3.2.5
      • Hibernate 3.5.3
      • hibernate-envers 3.5.3

       

      I have set Audited on EO Classes and configured envers like this :

      <persistence version="2.0"
          xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
          <persistence-unit name="VMS-test">
              <!-- Provider -->
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
              <!-- Class -->        
              <class>ch.softcomponent.morphean.vms.data.eo.OwnerGroupEO</class>
              
              <!-- Properties  -->
              <!-- overwriten by spring/dbcontext.xml -->
              <properties>
                  <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect" />
                  <property name="hibernate.archive.autodetection" value="none" />
                  <property name="hibernate.c3p0.max_statements" value="50" />
                  <property name="hibernate.cache.use_query_cache" value="false" />
                  <property name="hibernate.cache.use_second_level_cache" value="false" />
                  <property name="hibernate.format_sql" value="true" />
                  <property name="hibernate.hbm2ddl.auto" value="create-drop" />
                  <property name="hibernate.show_sql" value="false" />
                  <property name="use_sql_comments" value="true" />
                  <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
             
                  <property name="hibernate.auditable" value="true" />     
                  <property name="hibernate.ejb.event.post-insert" value="org.hibernate.envers.event.AuditEventListener" /> 
                  <property name="hibernate.ejb.event.post-update" value="org.hibernate.envers.event.AuditEventListener" /> 
                  <property name="hibernate.ejb.event.post-delete" value="org.hibernate.envers.event.AuditEventListener" /> 
                  <property name="hibernate.ejb.event.pre-collection-update" value="org.hibernate.envers.event.AuditEventListener" /> 
                  <property name="hibernate.ejb.event.pre-collection-remove" value="org.hibernate.envers.event.AuditEventListener" /> 
                  <property name="hibernate.ejb.event.post-collection-recreate" value="org.hibernate.envers.event.AuditEventListener" /> 
                                <!-- Properties for Hibernate Envers -->
                  <property name="org.hibernate.envers.audit_table_suffix" value="_HISTO" />
                  
              </properties>
          </persistence-unit>
      </persistence>
      

       

      By Update on OwnerGroupEO, the AuditEventListener.onPostUpdate() is called, but the org.hibernate.envers.synchronization.AuditProcess.doBeforeTransactionCompletion(SessionImplementor) is never called and consequently the _AUD table are never filled.

       

      I made a JUnit Tests like this:

          @Test
          @Transactional(propagation = Propagation.REQUIRES_NEW)
          public void testAuditedOwner2() throws Exception {
              OwnerGroupEO ownerGrp2 = ownerGroupDAO.getOwnerGroup(OWNER_GROUP_ID);
              ownerGrp2.setHorusLocation("horusLocation2");
             
              ownerGroupDAO.getEm().merge(ownerGrp2);
          }
      

       

      In this case the _AUD table and REVINFO table are filled. And I can see that org.hibernate.envers.synchronization.AuditProcess.doBeforeTransactionCompletion(SessionImplementor) is called.


      I feel that this is a problem of transaction. The process is registred, but it is clean before the call from JDBCTransaction.commit() -> notifyLocalSynchsBeforeTransactionCompletion(); if ( callback ) {jdbcContext.beforeTransactionCompletion( this );}.

       

      Did you an Idea ?

       

      Thanks

      Yves