2 Replies Latest reply on Apr 23, 2011 6:47 PM by santhi_krishna

    Hibernate Envers - Data is not inserting into audit tables after post-insert callback

    santhi_krishna Newbie


         I am using Hibernate v3.6.0 Fianl with Spring v3.0.5. I configured Post-insert audit listener of Envers and it is being called after inserting data into the primary table, but it is not inserting into audit table. It is printing insert query for primary table, but not for audit table.

        I don't see any error in log files. I see RelationDescription relDesc = entCfg.getRelationDescription(propertyName); code in EntitiesConfigurations class and relDesc is null for all my properties of entity class.


      I am using JPA annotations on my entity class, but using Hibernate ORM. I have @audited annotation on my class.



      What am doing wrong? I see post-insert listener getting called, but audit table is not inserted.


      I appreciate your help.


      <property name="hibernateProperties">





                                              <!-- Hibernate recommends all new projects to use hibernate.id.new_generator_mappings=true

                                              as the new generators are more efficient and closer to the JPA 2 specification semantic.

                                              However they are not backward compatible with existing databases (if a sequence or a table is used for id generation).



                                              <!-- EHCache setup for code table data



                                              hibernate.cache.region.factory_class=net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory -->


                                              <!-- Envers for audit trail -->











        <!-- Envers - Auditlogging Begin  VK-->

         <property name="eventListeners">


               <entry key="post-insert">


                         <ref bean="ejb3PostInsertEventListener" />

                         <ref local="enversListener"/>



               <entry key="post-update"><ref local="enversListener"/></entry>

               <entry key="post-delete"><ref local="enversListener"/></entry>

               <entry key="pre-collection-update"><ref local="enversListener"/></entry>

               <entry key="pre-collection-remove"><ref local="enversListener"/></entry>

               <entry key="post-collection-recreate"><ref local="enversListener"/></entry>


                <!-- The following added to take care of setting timestamps and create and update user ids globally

                                                    for persisted objects - VK--> 

               <entry key="pre-insert"><ref local="housekeepingListener"/></entry>

               <entry key="pre-update"><ref local="housekeepingListener"/></entry>        








      <!--bean id="enversListener" class="org.hibernate.envers.event.AuditEventListener"/-->

      <bean id="enversListener" class="com.cvscaremark.links.util.LinksAuditEventListener"/>

      <bean id="housekeepingListener" class="com.cvscaremark.links.util.TracabilityListener"/>