Package org.hibernate
Class EmptyInterceptor
java.lang.Object
org.hibernate.EmptyInterceptor
- All Implemented Interfaces:
Serializable,Interceptor
An interceptor that does nothing. May be used as a base class
for application-defined custom interceptors.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when a Hibernate transaction is begun via the Hibernate Transaction API.voidCalled after a transaction is committed or rolled back.voidCalled before a transaction is committed (but not before rollback).int[]findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) Called from flush().getEntity(String entityName, Serializable id) Get a fully loaded entity instance that is cached externallygetEntityName(Object object) Get the entity name for a persistent or transient instanceinstantiate(String entityName, EntityMode entityMode, Serializable id) Instantiate the entity class.isTransient(Object entity) Called to distinguish between transient and detached entities.voidonCollectionRecreate(Object collection, Serializable key) Called before a collection is (re)created.voidonCollectionRemove(Object collection, Serializable key) Called before a collection is deleted.voidonCollectionUpdate(Object collection, Serializable key) Called before a collection is updated.voidCalled before an object is deleted.booleanonFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) Called when an object is detected to be dirty, during a flush.booleanCalled just before an object is initialized.onPrepareStatement(String sql) Called when sql string is being prepared.booleanCalled before an object is saved.voidCalled after a flush that actually ends in execution of the SQL statements required to synchronize in-memory state with the database.voidCalled before a flush
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
EmptyInterceptor
protected EmptyInterceptor()
-
-
Method Details
-
onDelete
public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) Description copied from interface:InterceptorCalled before an object is deleted. It is not recommended that the interceptor modify the state.- Specified by:
onDeletein interfaceInterceptor
-
onFlushDirty
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) Description copied from interface:InterceptorCalled when an object is detected to be dirty, during a flush. The interceptor may modify the detected currentState, which will be propagated to both the database and the persistent object. Note that not all flushes end in actual synchronization with the database, in which case the new currentState will be propagated to the object, but not necessarily (immediately) to the database. It is strongly recommended that the interceptor not modify the previousState.- Specified by:
onFlushDirtyin interfaceInterceptor- Returns:
- true if the user modified the currentState in any way.
-
onLoad
public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) Description copied from interface:InterceptorCalled just before an object is initialized. The interceptor may change the state, which will be propagated to the persistent object. Note that when this method is called, entity will be an empty uninitialized instance of the class.- Specified by:
onLoadin interfaceInterceptor- Returns:
- true if the user modified the state in any way.
-
onSave
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) Description copied from interface:InterceptorCalled before an object is saved. The interceptor may modify the state, which will be used for the SQL INSERT and propagated to the persistent object.- Specified by:
onSavein interfaceInterceptor- Returns:
- true if the user modified the state in any way.
-
postFlush
Description copied from interface:InterceptorCalled after a flush that actually ends in execution of the SQL statements required to synchronize in-memory state with the database.- Specified by:
postFlushin interfaceInterceptor
-
preFlush
Description copied from interface:InterceptorCalled before a flush- Specified by:
preFlushin interfaceInterceptor
-
isTransient
Description copied from interface:InterceptorCalled to distinguish between transient and detached entities. The return value determines the state of the entity with respect to the current session.- Boolean.TRUE - the entity is transient
- Boolean.FALSE - the entity is detached
- null - Hibernate uses the unsaved-value mapping and other heuristics to determine if the object is unsaved
- Specified by:
isTransientin interfaceInterceptor- Parameters:
entity- a transient or detached entity- Returns:
- Boolean or null to choose default behaviour
-
instantiate
Description copied from interface:InterceptorInstantiate the entity class. Return null to indicate that Hibernate should use the default constructor of the class. The identifier property of the returned instance should be initialized with the given identifier.- Specified by:
instantiatein interfaceInterceptor- Parameters:
entityName- the name of the entityentityMode- The type of entity instance to be returned.id- the identifier of the new instance- Returns:
- an instance of the class, or null to choose default behaviour
-
findDirty
public int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) Description copied from interface:InterceptorCalled from flush(). The return value determines whether the entity is updated- an array of property indices - the entity is dirty
- an empty array - the entity is not dirty
- null - use Hibernate's default dirty-checking algorithm
- Specified by:
findDirtyin interfaceInterceptor- Parameters:
entity- a persistent entity- Returns:
- array of dirty property indices or null to choose default behaviour
-
getEntityName
Description copied from interface:InterceptorGet the entity name for a persistent or transient instance- Specified by:
getEntityNamein interfaceInterceptor- Parameters:
object- an entity instance- Returns:
- the name of the entity
-
getEntity
Description copied from interface:InterceptorGet a fully loaded entity instance that is cached externally- Specified by:
getEntityin interfaceInterceptor- Parameters:
entityName- the name of the entityid- the instance identifier- Returns:
- a fully initialized entity
-
afterTransactionBegin
Description copied from interface:InterceptorCalled when a Hibernate transaction is begun via the Hibernate Transaction API. Will not be called if transactions are being controlled via some other mechanism (CMT, for example).- Specified by:
afterTransactionBeginin interfaceInterceptor
-
afterTransactionCompletion
Description copied from interface:InterceptorCalled after a transaction is committed or rolled back.- Specified by:
afterTransactionCompletionin interfaceInterceptor
-
beforeTransactionCompletion
Description copied from interface:InterceptorCalled before a transaction is committed (but not before rollback).- Specified by:
beforeTransactionCompletionin interfaceInterceptor
-
onPrepareStatement
Description copied from interface:InterceptorCalled when sql string is being prepared.- Specified by:
onPrepareStatementin interfaceInterceptor- Parameters:
sql- sql to be prepared- Returns:
- original or modified sql
-
onCollectionRemove
Description copied from interface:InterceptorCalled before a collection is deleted.- Specified by:
onCollectionRemovein interfaceInterceptor- Throws:
CallbackException
-
onCollectionRecreate
Description copied from interface:InterceptorCalled before a collection is (re)created.- Specified by:
onCollectionRecreatein interfaceInterceptor- Throws:
CallbackException
-
onCollectionUpdate
Description copied from interface:InterceptorCalled before a collection is updated.- Specified by:
onCollectionUpdatein interfaceInterceptor- Throws:
CallbackException
-