public class EmptyInterceptor extends Object implements Interceptor, Serializable
An interceptor that does nothing. May be used as a base class for application-defined custom interceptors.
Modifier and Type | Field and Description |
---|---|
static Interceptor |
INSTANCE
The singleton reference.
|
Modifier | Constructor and Description |
---|---|
protected |
EmptyInterceptor() |
Modifier and Type | Method and Description |
---|---|
void |
afterTransactionBegin(Transaction tx)
Called when a Hibernate transaction is begun via the Hibernate <tt>Transaction</tt>
API.
|
void |
afterTransactionCompletion(Transaction tx)
Called after a transaction is committed or rolled back.
|
void |
beforeTransactionCompletion(Transaction tx)
Called 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 <tt>flush()</tt>.
|
Object |
getEntity(String entityName,
Serializable id)
Get a fully loaded entity instance that is cached externally.
|
String |
getEntityName(Object object)
Get the entity name for a persistent or transient instance.
|
Object |
instantiate(String entityName,
EntityMode entityMode,
Serializable id)
Instantiate the entity class.
|
Boolean |
isTransient(Object entity)
Called to distinguish between transient and detached entities.
|
void |
onCollectionRecreate(Object collection,
Serializable key)
Called before a collection is (re)created.
|
void |
onCollectionRemove(Object collection,
Serializable key)
Called before a collection is deleted.
|
void |
onCollectionUpdate(Object collection,
Serializable key)
Called before a collection is updated.
|
void |
onDelete(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types)
Called before an object is deleted.
|
boolean |
onFlushDirty(Object entity,
Serializable 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,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types)
Called just before an object is initialized.
|
String |
onPrepareStatement(String sql)
Called when sql string is being prepared.
|
boolean |
onSave(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types)
Called before an object is saved.
|
void |
postFlush(Iterator entities)
Called after a flush that actually ends in execution of the SQL statements required to synchronize
in-memory state with the database.
|
void |
preFlush(Iterator entities)
Called before a flush.
|
public static final Interceptor INSTANCE
The singleton reference.
public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
Interceptor
Called before an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>.
onDelete
in interface Interceptor
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 propertiespublic boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types)
Interceptor
Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected <tt>currentState</tt>, 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 <tt>currentState</tt> will be propagated to the object, but not necessarily (immediately) to the database. It is strongly recommended that the interceptor <b>not</b> modify the <tt>previousState</tt>. <p/> NOTE: The indexes across the <tt>currentState</tt>, <tt>previousState</tt>, <tt>propertyNames</tt> and <tt>types</tt> arrays match.
onFlushDirty
in interface Interceptor
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 propertiestrue
if the user modified the <tt>currentState</tt> in any way.public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
Interceptor
Called just before an object is initialized. The interceptor may change the <tt>state</tt>, which will be propagated to the persistent object. Note that when this method is called, <tt>entity</tt> will be an empty uninitialized instance of the class. <p/> NOTE: The indexes across the <tt>state</tt>, <tt>propertyNames</tt> and <tt>types</tt> arrays match.
onLoad
in interface Interceptor
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 the <tt>state</tt>.types
- The types of the entity properties, corresponding to the <tt>state</tt>.true
if the user modified the <tt>state</tt> in any way.public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
Interceptor
Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for the SQL <tt>INSERT</tt> and propagated to the persistent object.
onSave
in interface Interceptor
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 propertiespublic void postFlush(Iterator entities)
Interceptor
Called after a flush that actually ends in execution of the SQL statements required to synchronize in-memory state with the database.
postFlush
in interface Interceptor
entities
- The entities that were flushed.public void preFlush(Iterator entities)
Interceptor
Called before a flush.
preFlush
in interface Interceptor
entities
- The entities to be flushed.public Boolean isTransient(Object entity)
Interceptor
Called to distinguish between transient and detached entities. The return value determines the state of the entity with respect to the current session. <ul> <li><tt>Boolean.TRUE</tt> - the entity is transient <li><tt>Boolean.FALSE</tt> - the entity is detached <li><tt>null</tt> - Hibernate uses the <tt>unsaved-value</tt> mapping and other heuristics to determine if the object is unsaved </ul>
isTransient
in interface Interceptor
entity
- a transient or detached entitypublic Object instantiate(String entityName, EntityMode entityMode, Serializable id)
Interceptor
Instantiate the entity class. Return <tt>null</tt> 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.
instantiate
in interface Interceptor
entityName
- the name of the entityentityMode
- The type of entity instance to be returned.id
- the identifier of the new instancepublic int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types)
Interceptor
Called from <tt>flush()</tt>. The return value determines whether the entity is updated <ul> <li>an array of property indices - the entity is dirty <li>an empty array - the entity is not dirty <li><tt>null</tt> - use Hibernate’s default dirty-checking algorithm </ul>
findDirty
in interface Interceptor
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 propertiesnull
to indicate Hibernate should perform default behaviourpublic String getEntityName(Object object)
Interceptor
Get the entity name for a persistent or transient instance.
getEntityName
in interface Interceptor
object
- an entity instancepublic Object getEntity(String entityName, Serializable id)
Interceptor
Get a fully loaded entity instance that is cached externally.
getEntity
in interface Interceptor
entityName
- the name of the entityid
- the instance identifierpublic void afterTransactionBegin(Transaction tx)
Interceptor
Called when a Hibernate transaction is begun via the Hibernate <tt>Transaction</tt> API. Will not be called if transactions are being controlled via some other mechanism (CMT, for example).
afterTransactionBegin
in interface Interceptor
tx
- The Hibernate transaction facade objectpublic void afterTransactionCompletion(Transaction tx)
Interceptor
Called after a transaction is committed or rolled back.
afterTransactionCompletion
in interface Interceptor
tx
- The Hibernate transaction facade objectpublic void beforeTransactionCompletion(Transaction tx)
Interceptor
Called before a transaction is committed (but not before rollback).
beforeTransactionCompletion
in interface Interceptor
tx
- The Hibernate transaction facade objectpublic String onPrepareStatement(String sql)
Interceptor
Called when sql string is being prepared.
onPrepareStatement
in interface Interceptor
sql
- sql to be preparedpublic void onCollectionRemove(Object collection, Serializable key) throws CallbackException
Interceptor
Called before a collection is deleted.
onCollectionRemove
in interface Interceptor
collection
- The collection instance.key
- The collection key value.CallbackException
- Thrown if the interceptor encounters any problems handling the callback.public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException
Interceptor
Called before a collection is (re)created.
onCollectionRecreate
in interface Interceptor
collection
- The collection instance.key
- The collection key value.CallbackException
- Thrown if the interceptor encounters any problems handling the callback.public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException
Interceptor
Called before a collection is updated.
onCollectionUpdate
in interface Interceptor
collection
- The collection instance.key
- The collection key value.CallbackException
- Thrown if the interceptor encounters any problems handling the callback.Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.