Class AuditableInterceptor

  extended by org.hibernate.EmptyInterceptor
      extended by org.openmrs.api.db.hibernate.AuditableInterceptor
All Implemented Interfaces:, org.hibernate.Interceptor

public class AuditableInterceptor
extends org.hibernate.EmptyInterceptor

This class looks for Auditable that are being inserted into the database. When found, if the class is an update (instead of an insert) then the changedBy and dateChanged fields are set to the current user and the current time.

This class replaces the logic that was in the AuditableSaveHandler. It is here so that the cascading does NOT happen for dateChanged/changedBy to child OpenmrsObjects (because all handlers recurse on lists of OpenmrsObjects.

See Also:
Serialized Form

Field Summary
Fields inherited from class org.hibernate.EmptyInterceptor
Constructor Summary
Method Summary
 boolean onFlushDirty(java.lang.Object entity, id, java.lang.Object[] currentState, java.lang.Object[] previousState, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
          This class method is only called when flushing an updated dirty object, not inserting objects
Methods inherited from class org.hibernate.EmptyInterceptor
afterTransactionBegin, afterTransactionCompletion, beforeTransactionCompletion, findDirty, getEntity, getEntityName, instantiate, isTransient, onCollectionRecreate, onCollectionRemove, onCollectionUpdate, onDelete, onLoad, onPrepareStatement, onSave, postFlush, preFlush
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public AuditableInterceptor()
Method Detail


public boolean onFlushDirty(java.lang.Object entity,
                            java.lang.Object[] currentState,
                            java.lang.Object[] previousState,
                            java.lang.String[] propertyNames,
                            org.hibernate.type.Type[] types)
                     throws org.hibernate.CallbackException
This class method is only called when flushing an updated dirty object, not inserting objects

Specified by:
onFlushDirty in interface org.hibernate.Interceptor
onFlushDirty in class org.hibernate.EmptyInterceptor
true if the object got the changedBy and dateChanged fields set
See Also:
EmptyInterceptor.onFlushDirty(java.lang.Object,, java.lang.Object[], java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
Expected behavior:
return false for non Auditable objects, set the dateChanged field, set the changedBy field, be called when saving an Auditable


Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change