0 Replies Latest reply: Apr 30, 2012 11:16 AM by dhaval patil RSS

Hibernate Envers 3.5.6+Spring 3 +JPA-No Audit Tables & Entries

dhaval patil Newbie

Hi,

 

I am using hibernate Envers (version 3.5.6) with JPA and Spring 3. I have below setting in my spring settings (applicationcontext.xml) 

 

<tx:annotation-driven transaction-manager="transactionManager"/>

<bean id="auditEventListener" class="org.hibernate.envers.event.AuditEventListener"/>

    <bean id="callbackHandler" class="org.hibernate.ejb.event.EntityCallbackHandler" />

 

    <bean id="ejb3PostInsertEventListener" class="org.hibernate.ejb.event.EJB3PostInsertEventListener">

    <property name="callbackHandler">

    <ref bean="callbackHandler" />

    </property>

    </bean>

 

    <bean id="ejb3PostUpdateEventListener" class="org.hibernate.ejb.event.EJB3PostUpdateEventListener">

    <property name="callbackHandler">

    <ref bean="callbackHandler" />

    </property>

    </bean>

 

    <bean id="ejb3PostDeleteEventListener" class="org.hibernate.ejb.event.EJB3PostDeleteEventListener">

    <property name="callbackHandler">

    <ref bean="callbackHandler" />

    </property>

    </bean>

 

    <bean id="mySessionFactory"

        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

        <property name="dataSource" ref="myDataSource" />

        <property name="packagesToScan" value="com.wipro.edo.entities" />

        <property name="hibernateProperties">

            <value>               

                hibernate.hbm2ddl.auto = update  

            </value>

        </property>

       

        <property name="eventListeners">

            <map>

                <entry key="post-insert">

                <list>

                <ref bean="ejb3PostInsertEventListener" />

                <ref bean="auditEventListener" />

                </list>

                </entry>

               

                <entry key="post-update">

                <list>

                <ref bean="ejb3PostUpdateEventListener" />

                <ref bean="auditEventListener" />

                </list>

                </entry>

               

                <entry key="post-delete">

                <list>

                <ref bean="ejb3PostDeleteEventListener" />

                <ref bean="auditEventListener" />

                </list>

                </entry>

               

                <entry key="pre-collection-update">

                <ref bean="auditEventListener" />

                </entry>

               

                <entry key="pre-collection-remove">

                <ref bean="auditEventListener" />

                </entry>

               

                <entry key="post-collection-recreate">

                <ref bean="auditEventListener" />

                </entry>

            </map>

        </property>

    </bean>

   

    <!-- Drives transactions using local JPA APIs -->

   

      <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">

       <!-- <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> -->

              <!-- <property name="sessionFactory" ref="mySessionFactory" /> -->

               <property name="entityManagerFactory" ref="entityManagerFactory" />

              <property name="dataSource" ref="myDataSource" />

 

    </bean>

 

In the logs , I do see org.hibernate.envers.DefaultRevisionEntity getting called. I do not see the AuditEventListener getting initialized, the audit tables are also not getting created inspite of having hibernate.hbm2ddl.auto = update as mentioned above. In terms of the jars , I use :

1.hibernate-core-3.5.6-Final.jar

2.hibernate-entitymanager-3.5.6-Final.jar

3.hibernate-envers-3.5.6-Final.jar

4.hibernate-jpa-2.0-api-1.0.0.Final.jar

 

I do the below logged statements :

19.04.2012 20:13:36 *DEBUG* HbmBinder: Mapped property: REVTYPE -> REVTYPE (HbmBinder.java, line 1335)

19.04.2012 20:13:36 *DEBUG* HbmBinder: Mapped property: REVTYPE -> REVTYPE (HbmBinder.java, line 1335)

19.04.2012 20:13:36 *INFO * HbmBinder: Mapping class: com.wipro.edo.entities.EDOPermission_AUD -> tbl_Permission_AUD (HbmBinder.java, line 348)

19.04.2012 20:13:36 *INFO * HbmBinder: Mapping class: com.wipro.edo.entities.EDOPermission_AUD -> tbl_Permission_AUD (HbmBinder.java, line 348)

 

I do not see the audit tables nor the entries in the database, would be great if anyone can offer a clue.Please do also let me know if more information is needed.