com.basilv.examples.hibernate
Class AuditInterceptor
java.lang.Object
org.hibernate.EmptyInterceptor
com.basilv.examples.hibernate.AuditInterceptor
- All Implemented Interfaces:
- Serializable, org.hibernate.Interceptor
public class AuditInterceptor
- extends org.hibernate.EmptyInterceptor
AuditInterceptor is used to populate the audit fields on onUpdate and onSave events.
- See Also:
- Serialized Form
| Fields inherited from class org.hibernate.EmptyInterceptor |
INSTANCE |
| Methods inherited from class org.hibernate.EmptyInterceptor |
afterTransactionBegin, afterTransactionCompletion, beforeTransactionCompletion, findDirty, getEntity, getEntityName, instantiate, isTransient, onCollectionRecreate, onCollectionRemove, onCollectionUpdate, onDelete, onLoad, onPrepareStatement, postFlush, preFlush |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AuditInterceptor
public AuditInterceptor()
setUserForCurrentThread
public static void setUserForCurrentThread(String user)
- Store the user for the current thread.
- Parameters:
user - Cannot be null or empty.
getUserForCurrentThread
public static String getUserForCurrentThread()
- Get the user for the current thread.
(Used primarily for testing).
- Returns:
- the current user.
onFlushDirty
public boolean onFlushDirty(Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
org.hibernate.type.Type[] types)
- Specified by:
onFlushDirty in interface org.hibernate.Interceptor- Overrides:
onFlushDirty in class org.hibernate.EmptyInterceptor
onSave
public boolean onSave(Object entity,
Serializable id,
Object[] currentState,
String[] propertyNames,
org.hibernate.type.Type[] types)
- Specified by:
onSave in interface org.hibernate.Interceptor- Overrides:
onSave in class org.hibernate.EmptyInterceptor
Java Examples available from http://www.basilv.com/psd/software Copyright © 2009 by Basil Vandegriend. All Rights Reserved.