Envers doesn't insert records

后端 未结 1 1301
天命终不由人
天命终不由人 2021-01-28 07:08

I\'m trying to integrate Envers in my project. I\'m using Hibernate-envers 3.5.5-Final, Hibernate-core 3.5.5-Final, spring 3.0.7.RELEASE.

For DAO Layer, I\'m using a Gen

相关标签:
1条回答
  • 2021-01-28 07:43

    OK.

    I solved the problem.

    Firstibale, it seems that with the Hibernate-core 3.5.5-Final, we don't need org.hibernate.ejb.event.EJB3PostInsertEventListener, so in our ApplicationContext-config.xml we should have just this config :

    <property name="eventListeners">
                       <map>
                       <entry key="post-insert" >
                             <bean class="org.hibernate.envers.event.AuditEventListener" />
                     </entry>
                        <entry key="post-update">
                         <bean class="org.hibernate.envers.event.AuditEventListener" />
                       </entry>
                        <entry key="post-delete">
                         <bean class="org.hibernate.envers.event.AuditEventListener" />
                       </entry>
                        <entry key="pre-collection-update">
                         <bean class="org.hibernate.envers.event.AuditEventListener" />
                       </entry>
                        <entry key="pre-collection-remove">
                         <bean class="org.hibernate.envers.event.AuditEventListener" />
                       </entry>
                        <entry key="post-collection-recreate">
                         <bean class="org.hibernate.envers.event.AuditEventListener" />
                       </entry>  
                       </map>
                    </property>
    

    Secondly, in our case our project uses two transction managers, so for the services annotated @Transactionnal we have to mention the name of the proper transaction manager used, that means that all services should be annotated as @Transactionnal(value="NAME_TX_MANAGER"). The source of this problem is that Envers doesn't work properly if we have an auto-commit (If I understood well its documentation).

    I hope that may be helpful for the other visitors if the face the same difficulties.

    0 讨论(0)
提交回复
热议问题