Class AuditingEntityListener

java.lang.Object
org.springframework.data.jpa.domain.support.AuditingEntityListener

@Configurable public class AuditingEntityListener extends Object
JPA entity listener to capture auditing information on persisting 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.support.AuditingEntityListener" />
         </entity-listeners>
     </persistence-unit-defaults>
 </persistence-unit-metadata>
 
After that it's just a matter of activating auditing in your Spring config:
 @Configuration
 @EnableJpaAuditing
 class ApplicationConfig {

 }
 
 <jpa:auditing auditor-aware-ref="yourAuditorAwarebean" />
 
Author:
Oliver Gierke, Thomas Darimont, Christoph Strobl, Mark Paluch
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    setAuditingHandler(org.springframework.beans.factory.ObjectFactory<org.springframework.data.auditing.AuditingHandler> auditingHandler)
    Configures the AuditingHandler to be used to set the current auditor on the domain types touched.
    void
    Sets modification and creation date and auditor on the target object in case it implements Auditable on persist events.
    void
    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 Details

    • AuditingEntityListener

      public AuditingEntityListener()
  • Method Details

    • setAuditingHandler

      public void setAuditingHandler(org.springframework.beans.factory.ObjectFactory<org.springframework.data.auditing.AuditingHandler> auditingHandler)
      Configures the AuditingHandler to be used to set the current auditor on the domain types touched.
      Parameters:
      auditingHandler - must not be null.
    • 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 -