I'm having a problem getting Hibernate Envers to work in our environment. We are using Spring 3.x with LoadTimeWeaving. Below is our context file:
Here is our persistence.xmlCode:<context:annotation-config/> <context:spring-configured/> <context:load-time-weaver aspectj-weaving="autodetect"/> <context:component-scan base-package="com.company.app"/> <context:property-placeholder location="classpath:db/database-test.properties"/> <bean id="dataSourcePooled" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" p:jdbcUrl="${database.url}" p:user="${database.username}" p:password="${database.password}" p:initialPoolSize="1" p:maxPoolSize="5" p:idleConnectionTestPeriod="500" p:acquireIncrement="1" p:maxStatements="50" p:numHelperThreads="1" p:autoCommitOnClose="true"/> <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" p:databasePlatform="${database.platform}" p:showSql="${database.showSql}" p:generateDdl="${database.generateDdl}"/> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:persistenceUnitName="TEST" p:persistenceXmlLocation="META-INF/persistence.xml" p:dataSource-ref="dataSourcePooled" p:jpaVendorAdapter-ref="jpaAdapter"> <property name="loadTimeWeaver"> <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="entityManagerFactory" p:dataSource-ref="dataSourcePooled"/> <tx:annotation-driven transaction-manager="transactionManager"/> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
The audit tables are setup correctly, but when an entity is persisted there are no records stored in the audit tables. There are only two fields that are audited. Also, because we are using loadTimeWeaving, when we run unit test, we are required to have -javaagent:/Users/TEST/.m2/repository/org/springframework/spring-instrument/3.0.3.RELEASE/spring-instrument-3.0.3.RELEASE.jar as a JVM argument so the loadTimeWeaving works.Code:<persistence-unit name="TEST" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <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> </persistence-unit>
Aside from Envers, everything else works fine.
AS as side note, I did remove the weaving to see if that made a difference, but it had no effect.
Any help would be much appreciated.


Reply With Quote
