Package org.hibernate.internal
Class EmptyInterceptor
java.lang.Object
org.hibernate.internal.EmptyInterceptor
- All Implemented Interfaces:
Serializable
,Interceptor
An interceptor that does nothing.
This is an internal class and should not be used as a base to implement a custom Interceptor;
it is similar to the public, deprecated
EmptyInterceptor
but overrides
the default methods for sake of efficiency: this wasn't possible on the original deprecated
copy as that wouldn't have been backwards compatible. For this reason this copy is internal.
Implementors of Interceptor don't need a base class anymore since we now have default
implementations of the contract defined in the interface.- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionint[]
findDirty
(Object entity, Object id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) Called fromflush()
.Get a fully loaded entity instance that is cached externally.void
Called before an object is removed by a stateful session.boolean
onFlushDirty
(Object entity, Object id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) Called when an object is detected to be dirty, during a flush.boolean
Called just before an object is initialized.boolean
Called before an object is made persistent by a stateful session.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.hibernate.Interceptor
afterTransactionBegin, afterTransactionCompletion, beforeTransactionCompletion, findDirty, getEntity, getEntityName, instantiate, instantiate, isTransient, onCollectionRecreate, onCollectionRecreate, onCollectionRemove, onCollectionRemove, onCollectionUpdate, onCollectionUpdate, onDelete, onDelete, onFlushDirty, onInsert, onLoad, onPersist, onRemove, onSave, onUpdate, onUpsert, postFlush, preFlush
-
Field Details
-
INSTANCE
-
-
Method Details
-
onLoad
public boolean onLoad(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types) Description copied from interface:Interceptor
Called just before an object is initialized. The interceptor may change thestate
, 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:
onLoad
in interfaceInterceptor
- Parameters:
entity
- The entity instance being loadedid
- The identifier value being loadedstate
- The entity state (which will be pushed into the entity instance)propertyNames
- The names of the entity properties, corresponding to thestate
.types
- The types of the entity properties, corresponding to thestate
.- Returns:
true
if the user modified thestate
in any way.
-
onFlushDirty
public boolean onFlushDirty(Object entity, Object id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) Description copied from interface:Interceptor
Called when an object is detected to be dirty, during a flush. The interceptor may modify the detectedcurrentState
, 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 newcurrentState
will be propagated to the object, but not necessarily (immediately) to the database. It is strongly recommended that the interceptor not modify thepreviousState
.- Specified by:
onFlushDirty
in interfaceInterceptor
- Parameters:
entity
- The entity instance detected as being dirty and being flushedid
- The identifier of the entitycurrentState
- The entity's current statepreviousState
- The entity's previous (load time) state.propertyNames
- The names of the entity propertiestypes
- The types of the entity properties- Returns:
true
if the user modified thecurrentState
in any way.- See Also:
-
onSave
public boolean onSave(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types) Description copied from interface:Interceptor
Called before an object is made persistent by a stateful session.The interceptor may modify the
state
, which will be used for the SQLINSERT
and propagated to the persistent object.- Specified by:
onSave
in interfaceInterceptor
- Parameters:
entity
- The entity instance whose state is being insertedid
- The identifier of the entitystate
- The state of the entity which will be insertedpropertyNames
- The names of the entity properties.types
- The types of the entity properties- Returns:
true
if the user modified thestate
in any way.- See Also:
-
onDelete
public void onDelete(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types) Description copied from interface:Interceptor
Called before an object is removed by a stateful session.It is not recommended that the interceptor modify the
state
.- Specified by:
onDelete
in interfaceInterceptor
- Parameters:
entity
- The entity instance being deletedid
- The identifier of the entitystate
- The state of the entitypropertyNames
- The names of the entity properties.types
- The types of the entity properties- See Also:
-
findDirty
public int[] findDirty(Object entity, Object id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) Description copied from interface:Interceptor
Called fromflush()
. 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:
findDirty
in interfaceInterceptor
- Parameters:
entity
- The entity for which to find dirty properties.id
- The identifier of the entitycurrentState
- The current entity state as taken from the entity instancepreviousState
- The state of the entity when it was last synchronized (generally when it was loaded)propertyNames
- The names of the entity properties.types
- The types of the entity properties- Returns:
- array of dirty property indices or
null
to indicate Hibernate should perform default behaviour
-
getEntity
Description copied from interface:Interceptor
Get a fully loaded entity instance that is cached externally.- Specified by:
getEntity
in interfaceInterceptor
- Parameters:
entityName
- the name of the entityid
- the instance identifier- Returns:
- a fully initialized entity
-