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

      Hello,

         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">

                <value>

                                              hibernate.dialect=org.hibernate.dialect.DB2Dialect

                                              hibernate.show_sql=true

                                              hibernate.id.new_generator_mappings=true

                                              <!-- 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.use_second_level_cache=true

                                              hibernate.cache.use_query_cache=true

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

       

                                              <!-- Envers for audit trail -->

                                              org.hibernate.envers.audit_table_suffix=_AUDIT

                                              org.hibernate.envers.revision_field_name=REVISION_ID

                                              org.hibernate.envers.revision_type_field_name=REVTYPE

                                              org.hibernate.envers.do_not_audit_optimistic_locking_field=true

                                              org.hibernate.envers.audit_strategy=org.hibernate.envers.strategy.DefaultAuditStrategy

       

                </value>

      </property>

       

       

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

         <property name="eventListeners">

            <map>

               <entry key="post-insert">

                 <list>

                         <ref bean="ejb3PostInsertEventListener" />

                         <ref local="enversListener"/>

                        </list>

               </entry>

               <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>        

            </map>

         </property> 

       

       

      </bean>

       

       

      <!--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"/>

       

       

      Thanks

      Venkat