edu.nrao.sss.dao
Class UpdateInterceptor

java.lang.Object
  extended by org.hibernate.EmptyInterceptor
      extended by edu.nrao.sss.dao.UpdateInterceptor
All Implemented Interfaces:
Serializable, org.hibernate.Interceptor

public class UpdateInterceptor
extends org.hibernate.EmptyInterceptor

UpdateInterceptor intercepts the onSave and onFlushDirty events in order to automatically set the fields of the UserAccountable interface.

See Also:
Interceptor, UserAccountable, Serialized Form

Field Summary
 
Fields inherited from class org.hibernate.EmptyInterceptor
INSTANCE
 
Constructor Summary
UpdateInterceptor(Long userId)
          Creates an UpdateInterceptor that changes the fields of the UserAccountable interface using userId.
 
Method Summary
 boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)
          This method updates the LastUpdatedOn and LastUpdatedBy fields of UserAccountable entities.
 boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types)
          This method updates the CreatedOn and CreatedBy fields of UserAccountable entities, as well as their LastUpdatedOn and LastUpdatedBy fields.
 
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

UpdateInterceptor

public UpdateInterceptor(Long userId)
Creates an UpdateInterceptor that changes the fields of the UserAccountable interface using userId.

Throws:
IllegalArgumentException - if userId is null or <= 0.
See Also:
UserAccountable
Method Detail

onSave

public boolean onSave(Object entity,
                      Serializable id,
                      Object[] state,
                      String[] propertyNames,
                      org.hibernate.type.Type[] types)
This method updates the CreatedOn and CreatedBy fields of UserAccountable entities, as well as their LastUpdatedOn and LastUpdatedBy fields.

Specified by:
onSave in interface org.hibernate.Interceptor
Overrides:
onSave in class org.hibernate.EmptyInterceptor

onFlushDirty

public boolean onFlushDirty(Object entity,
                            Serializable id,
                            Object[] currentState,
                            Object[] previousState,
                            String[] propertyNames,
                            org.hibernate.type.Type[] types)
This method updates the LastUpdatedOn and LastUpdatedBy fields of UserAccountable entities.

Specified by:
onFlushDirty in interface org.hibernate.Interceptor
Overrides:
onFlushDirty in class org.hibernate.EmptyInterceptor


Copyright © 2009. All Rights Reserved.