Class ChainedInterceptorSupport
- java.lang.Object
-
- org.springframework.orm.hibernate.support.ChainedInterceptorSupport
-
- All Implemented Interfaces:
org.hibernate.Interceptor
- Direct Known Subclasses:
DependencyInjectionInterceptorFactoryBean.DependencyInjectionInterceptor,DirtiedHibernateSessionObjectRecorder,HibernateObjectsAuditInterceptor,OidGenerationInterceptor,ReadOnlyGetMethodEnforcer
public abstract class ChainedInterceptorSupport extends Object implements org.hibernate.Interceptor
Support class for Hibernate interceptors that participate in a chain. Suggested by Seth Ladd and based by code contributed by Oliver Hutchison. Necessary as Hibernate does not support native chaining of interceptors.
Implements all Interceptor methods as no ops. Abstract as it will do nothing unless a subclass overrides one or more methods. Any methods that are not handled by the subclass will delegate to the next interceptor in the chain.- Since:
- 1.2
- Author:
- Rod Johnson
- See Also:
Interceptor
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.log4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description ChainedInterceptorSupport()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterTransactionBegin(org.hibernate.Transaction transaction)voidafterTransactionCompletion(org.hibernate.Transaction transaction)voidbeforeTransactionCompletion(org.hibernate.Transaction transaction)int[]findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)ObjectgetEntity(String entityName, Serializable serializable)StringgetEntityName(Object object)org.hibernate.InterceptorgetNextInterceptor()Objectinstantiate(String beanClass, org.hibernate.EntityMode entityMode, Serializable id)BooleanisTransient(Object entity)voidonCollectionRecreate(Object collection, Serializable key)voidonCollectionRemove(Object collection, Serializable key)voidonCollectionUpdate(Object collection, Serializable key)voidonDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types)booleanonFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)booleanonLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types)StringonPrepareStatement(String sql)booleanonSave(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types)voidpostFlush(Iterator entities)voidpreFlush(Iterator entities)protected static voidsetIdOnNewEntity(org.hibernate.SessionFactory sessionFactory, Class<?> persistentClass, Serializable id, Object newEntity)Convenience methods subclasses can use to apply the id to a new entity if they override the instantiate method.voidsetNextInterceptor(org.hibernate.Interceptor nextInterceptor)As Hibernate doesn't support chaining of interceptors natively, we add the ability for chaining via a delegate.
-
-
-
Method Detail
-
setNextInterceptor
public void setNextInterceptor(org.hibernate.Interceptor nextInterceptor)
As Hibernate doesn't support chaining of interceptors natively, we add the ability for chaining via a delegate.- Parameters:
nextInterceptor-
-
getNextInterceptor
public org.hibernate.Interceptor getNextInterceptor()
-
instantiate
public Object instantiate(String beanClass, org.hibernate.EntityMode entityMode, Serializable id) throws org.hibernate.CallbackException
- Specified by:
instantiatein interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException- See Also:
Interceptor.instantiate(java.lang.String, org.hibernate.EntityMode, java.io.Serializable)
-
onLoad
public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types) throws org.hibernate.CallbackException
- Specified by:
onLoadin interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException- See Also:
Interceptor.onLoad(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
-
onFlushDirty
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types) throws org.hibernate.CallbackException
- Specified by:
onFlushDirtyin interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException- See Also:
Interceptor.onFlushDirty(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
-
onSave
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types) throws org.hibernate.CallbackException
- Specified by:
onSavein interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException- See Also:
Interceptor.onSave(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
-
onDelete
public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types) throws org.hibernate.CallbackException
- Specified by:
onDeletein interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException- See Also:
Interceptor.onDelete(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
-
preFlush
public void preFlush(Iterator entities) throws org.hibernate.CallbackException
- Specified by:
preFlushin interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException- See Also:
Interceptor.preFlush(java.util.Iterator)
-
postFlush
public void postFlush(Iterator entities) throws org.hibernate.CallbackException
- Specified by:
postFlushin interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException- See Also:
Interceptor.postFlush(java.util.Iterator)
-
isTransient
public Boolean isTransient(Object entity)
- Specified by:
isTransientin interfaceorg.hibernate.Interceptor- See Also:
Interceptor.isTransient(Object)
-
findDirty
public int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)
- Specified by:
findDirtyin interfaceorg.hibernate.Interceptor- See Also:
Interceptor.findDirty(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
-
afterTransactionCompletion
public void afterTransactionCompletion(org.hibernate.Transaction transaction)
- Specified by:
afterTransactionCompletionin interfaceorg.hibernate.Interceptor
-
getEntityName
public String getEntityName(Object object) throws org.hibernate.CallbackException
- Specified by:
getEntityNamein interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException
-
getEntity
public Object getEntity(String entityName, Serializable serializable) throws org.hibernate.CallbackException
- Specified by:
getEntityin interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException
-
afterTransactionBegin
public void afterTransactionBegin(org.hibernate.Transaction transaction)
- Specified by:
afterTransactionBeginin interfaceorg.hibernate.Interceptor
-
beforeTransactionCompletion
public void beforeTransactionCompletion(org.hibernate.Transaction transaction)
- Specified by:
beforeTransactionCompletionin interfaceorg.hibernate.Interceptor
-
onCollectionRecreate
public void onCollectionRecreate(Object collection, Serializable key) throws org.hibernate.CallbackException
- Specified by:
onCollectionRecreatein interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException
-
onCollectionRemove
public void onCollectionRemove(Object collection, Serializable key) throws org.hibernate.CallbackException
- Specified by:
onCollectionRemovein interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException
-
onCollectionUpdate
public void onCollectionUpdate(Object collection, Serializable key) throws org.hibernate.CallbackException
- Specified by:
onCollectionUpdatein interfaceorg.hibernate.Interceptor- Throws:
org.hibernate.CallbackException
-
onPrepareStatement
public String onPrepareStatement(String sql)
- Specified by:
onPrepareStatementin interfaceorg.hibernate.Interceptor
-
setIdOnNewEntity
protected static void setIdOnNewEntity(org.hibernate.SessionFactory sessionFactory, Class<?> persistentClass, Serializable id, Object newEntity) throws org.hibernate.CallbackExceptionConvenience methods subclasses can use to apply the id to a new entity if they override the instantiate method.- Parameters:
persistentClass-id-newEntity-- Throws:
org.hibernate.CallbackException
-
-