org.itracker.persistence.dao
Class TimestampInterceptor
java.lang.Object
org.hibernate.EmptyInterceptor
org.itracker.persistence.dao.TimestampInterceptor
- All Implemented Interfaces:
- Serializable, org.hibernate.Interceptor
public class TimestampInterceptor
- extends org.hibernate.EmptyInterceptor
A Hibernate Interceptor that automatically sets the createDate
and lastModifiedDate of any AbstractEntity instance that is
inserted or updated.
- Author:
- johnny
- 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 |
TimestampInterceptor
public TimestampInterceptor()
onSave
public boolean onSave(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
org.hibernate.type.Type[] types)
- Called before inserting an item in the datastore.
The interceptor may modify the state, which will be used for
the SQL INSERT and propagated to the persistent object.
Automatically sets the createDate and lastModifiedDate properties.
- Specified by:
onSave in interface org.hibernate.Interceptor- Overrides:
onSave in class org.hibernate.EmptyInterceptor
- Returns:
- true if the timestamp was set and thus the state was modified
onFlushDirty
public boolean onFlushDirty(Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
org.hibernate.type.Type[] types)
- Called before updating the datastore.
Called when an object is detected to be dirty, during a flush.
The interceptor may modify the detected currentState, which will be
propagated to both the database and the persistent object.
Note that not all flushes end in actual synchronization
with the database, in which case the new currentState will be
propagated to the object, but not necessarily (immediately)
to the database. It is strongly recommended that the interceptor
not modify the previousState.
Automatically sets the lastModifiedDate property.
- Specified by:
onFlushDirty in interface org.hibernate.Interceptor- Overrides:
onFlushDirty in class org.hibernate.EmptyInterceptor
- Returns:
- true if the timestamp was set and thus the currentState was modified
Copyright © 2002-2012 itracker. All Rights Reserved.