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
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.
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterTransactionBegin
(org.hibernate.Transaction transaction) void
afterTransactionCompletion
(org.hibernate.Transaction transaction) void
beforeTransactionCompletion
(org.hibernate.Transaction transaction) int[]
findDirty
(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types) getEntity
(String entityName, Serializable serializable) getEntityName
(Object object) org.hibernate.Interceptor
instantiate
(String beanClass, org.hibernate.EntityMode entityMode, Serializable id) isTransient
(Object entity) void
onCollectionRecreate
(Object collection, Serializable key) void
onCollectionRemove
(Object collection, Serializable key) void
onCollectionUpdate
(Object collection, Serializable key) void
onDelete
(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types) boolean
onFlushDirty
(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types) boolean
onLoad
(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types) onPrepareStatement
(String sql) boolean
onSave
(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types) void
void
protected static void
setIdOnNewEntity
(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.void
setNextInterceptor
(org.hibernate.Interceptor nextInterceptor) As Hibernate doesn't support chaining of interceptors natively, we add the ability for chaining via a delegate.
-
Field Details
-
log
protected final org.apache.log4j.Logger log
-
-
Constructor Details
-
ChainedInterceptorSupport
public ChainedInterceptorSupport()
-
-
Method Details
-
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:
instantiate
in 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:
onLoad
in 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:
onFlushDirty
in 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:
onSave
in 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:
onDelete
in 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
- Specified by:
preFlush
in interfaceorg.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
- See Also:
-
Interceptor.preFlush(java.util.Iterator)
-
postFlush
- Specified by:
postFlush
in interfaceorg.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
- See Also:
-
Interceptor.postFlush(java.util.Iterator)
-
isTransient
- Specified by:
isTransient
in 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:
findDirty
in 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:
afterTransactionCompletion
in interfaceorg.hibernate.Interceptor
-
getEntityName
- Specified by:
getEntityName
in interfaceorg.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
-
getEntity
public Object getEntity(String entityName, Serializable serializable) throws org.hibernate.CallbackException - Specified by:
getEntity
in interfaceorg.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
-
afterTransactionBegin
public void afterTransactionBegin(org.hibernate.Transaction transaction) - Specified by:
afterTransactionBegin
in interfaceorg.hibernate.Interceptor
-
beforeTransactionCompletion
public void beforeTransactionCompletion(org.hibernate.Transaction transaction) - Specified by:
beforeTransactionCompletion
in interfaceorg.hibernate.Interceptor
-
onCollectionRecreate
public void onCollectionRecreate(Object collection, Serializable key) throws org.hibernate.CallbackException - Specified by:
onCollectionRecreate
in interfaceorg.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
-
onCollectionRemove
public void onCollectionRemove(Object collection, Serializable key) throws org.hibernate.CallbackException - Specified by:
onCollectionRemove
in interfaceorg.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
-
onCollectionUpdate
public void onCollectionUpdate(Object collection, Serializable key) throws org.hibernate.CallbackException - Specified by:
onCollectionUpdate
in interfaceorg.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
-
onPrepareStatement
- Specified by:
onPrepareStatement
in interfaceorg.hibernate.Interceptor
-
setIdOnNewEntity
protected static void setIdOnNewEntity(org.hibernate.SessionFactory sessionFactory, Class<?> persistentClass, Serializable id, Object newEntity) throws org.hibernate.CallbackException Convenience 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
-