Hi,
I am playing around with Spring Data JPA and thought I would give the AuditingEntityListener a try. I have followed instructions from here http://static.springsource.org/sprin.../#jpa.auditing and created my implementation of AuditorAware interface but I can't seem to get the listener to fire. (note I have not implemented the Auditable anywhere yet but I simply wanted to get my AuditorAware implementation to be invoked).
My persistence.xml looks like:
My orm looks like:Code:<persistence-unit name="spring-jpa" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <mapping-file>META-INF/orm.xml</mapping-file> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> <!-- value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop" means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database --> <property name="hibernate.hbm2ddl.auto" value="validate"/> <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/> <property name="hibernate.connection.charSet" value="UTF-8"/> <!-- Uncomment the following two properties for JBoss only --> <!-- property name="hibernate.validator.apply_to_ddl" value="false" /--> <!-- property name="hibernate.validator.autoregister_listeners" value="false" / --> </properties> </persistence-unit>
and I have registered the following in application context.Code:<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd" version="2.0"> <persistence-unit-metadata> <persistence-unit-defaults> <entity-listeners> <entity-listener class="org.springframework.data.jpa.domain.support.AuditingEntityListener" /> </entity-listeners> </persistence-unit-defaults> </persistence-unit-metadata> </entity-mappings>
But I can't get my LoggedInAware (implements AuditorAware) to be invoked.Code:<!-- Scan repositories for insert of Crud operations --> <jpa:repositories base-package="com.xxx.yyy.publisher.admin.dao.jpa" /> <!-- Set up Auditing Bean --> <jpa:auditing auditor-aware-ref="auditorAwareBean" /> <bean id="auditorAwareBean" class="com.xxx.yyy.publisher.admin.dao.jpa.LoggedInAware" />
Am I missing something? Any ideas more than welcome.
Cheers
Andreas


Reply With Quote