The Encog Project

org.encog.util.orm
Class DataObjectInterceptor

java.lang.Object
  extended by org.hibernate.EmptyInterceptor
      extended by org.encog.util.orm.DataObjectInterceptor
All Implemented Interfaces:
java.io.Serializable, org.hibernate.Interceptor

public class DataObjectInterceptor
extends org.hibernate.EmptyInterceptor

A simple Hibernate interceptor that ensures that the last update field on Encog database persisted objects are updated.

Author:
jheaton
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.hibernate.EmptyInterceptor
INSTANCE
 
Constructor Summary
DataObjectInterceptor()
           
 
Method Summary
 boolean onFlushDirty(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] currentState, java.lang.Object[] previousState, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
          Called when a object is flushed.
 boolean onSave(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
          Called when an object is saved.
 
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
 

Constructor Detail

DataObjectInterceptor

public DataObjectInterceptor()
Method Detail

onFlushDirty

public boolean onFlushDirty(java.lang.Object entity,
                            java.io.Serializable id,
                            java.lang.Object[] currentState,
                            java.lang.Object[] previousState,
                            java.lang.String[] propertyNames,
                            org.hibernate.type.Type[] types)
Called when a object is flushed. Used to set the lastUpdate field to the current date.

Specified by:
onFlushDirty in interface org.hibernate.Interceptor
Overrides:
onFlushDirty in class org.hibernate.EmptyInterceptor
Parameters:
entity - The object currently being processed.
id - The ID.
currentState - The current value of the fields.
previousState - The previous values of the fields.
propertyNames - The names of the fields.
types - The field types.
Returns:
True if a value changes.

onSave

public boolean onSave(java.lang.Object entity,
                      java.io.Serializable id,
                      java.lang.Object[] state,
                      java.lang.String[] propertyNames,
                      org.hibernate.type.Type[] types)
Called when an object is saved. Used to update the create field on initial object creation.

Specified by:
onSave in interface org.hibernate.Interceptor
Overrides:
onSave in class org.hibernate.EmptyInterceptor
Parameters:
entity - The object being saved.
id - The id of the object being saved.
state - The state of this object.
propertyNames - The names of the fields.
types - The field types.
Returns:
True if a change was made.

The Encog Project