Package org.hibernate.internal
Class EmptyInterceptor
- java.lang.Object
-
- org.hibernate.internal.EmptyInterceptor
-
- All Implemented Interfaces:
Serializable
,Interceptor
public final class EmptyInterceptor extends Object implements Interceptor, Serializable
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, deprecatedEmptyInterceptor
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Interceptor
INSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]
findDirty(Object entity, Object id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types)
Called fromflush()
.Object
getEntity(String entityName, Object id)
Get a fully loaded entity instance that is cached externally.void
onDelete(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
Called before an object is deleted.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
onLoad(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
Called just before an object is initialized.boolean
onSave(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
Called before an object is saved.-
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, onFlushDirty, onLoad, onSave, postFlush, preFlush
-
-
-
-
Field Detail
-
INSTANCE
public static final Interceptor INSTANCE
-
-
Method Detail
-
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.NOTE: The indexes across the
state
,propertyNames
andtypes
arrays match.- 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
.NOTE: The indexes across the
currentState
,previousState
,propertyNames
andtypes
arrays match.- 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.
-
onSave
public boolean onSave(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
Description copied from interface:Interceptor
Called before an object is saved. The interceptor may modify thestate
, 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.
-
onDelete
public void onDelete(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
Description copied from interface:Interceptor
Called before an object is deleted. It is not recommended that the interceptor modify thestate
.- 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
-
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
public Object getEntity(String entityName, Object id)
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
-
-