Spring Data JPA

org.springframework.data.jpa.domain.support
Class AuditingEntityListener<T>

java.lang.Object
  extended by org.springframework.data.jpa.domain.support.AuditingEntityListener<T>

@Configurable
public class AuditingEntityListener<T>
extends Object

JPA entity listener to capture auditing information on persiting and updating entities. To get this one flying be sure you configure it as entity listener in your orm.xml as follows:

 <persistence-unit-metadata>
     <persistence-unit-defaults>
         <entity-listeners>
             <entity-listener class="org.springframework.data.jpa.domain.auditing.support.AuditingEntityListener" />
         </entity-listeners>
     </persistence-unit-defaults>
 </persistence-unit-metadata>
 
After that it's just a matter of activating auditing in your Spring config:
 <jpa:auditing auditor-aware-ref="yourAuditorAwarebean" />
 

Author:
Oliver Gierke

Constructor Summary
AuditingEntityListener()
           
 
Method Summary
 void setAuditingHandler(AuditingHandler<T> auditingHandler)
           
 void touchForCreate(Object target)
          Sets modification and creation date and auditor on the target object in case it implements Auditable on persist events.
 void touchForUpdate(Object target)
          Sets modification and creation date and auditor on the target object in case it implements Auditable on update events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuditingEntityListener

public AuditingEntityListener()
Method Detail

setAuditingHandler

public void setAuditingHandler(AuditingHandler<T> auditingHandler)
Parameters:
auditingHandler - the handler to set

touchForCreate

public void touchForCreate(Object target)
Sets modification and creation date and auditor on the target object in case it implements Auditable on persist events.

Parameters:
target -

touchForUpdate

public void touchForUpdate(Object target)
Sets modification and creation date and auditor on the target object in case it implements Auditable on update events.

Parameters:
target -

Spring Data JPA

Copyright © 2011-2013-2013 SpringSource. All Rights Reserved.