An interceptor that does nothing. May be used as a base class
for application-defined custom interceptors.
afterTransactionBegin
public void afterTransactionBegin(Transaction tx)
Called 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).
- afterTransactionBegin in interface Interceptor
findDirty
public int[] findDirty(Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
Type[] types)
Called 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
- findDirty in interface Interceptor
entity
- a persistent entity
- array of dirty property indices or null to choose default behaviour
getEntity
public Object getEntity(String entityName,
Serializable id)
Get a fully loaded entity instance that is cached externally
- getEntity in interface Interceptor
entityName
- the name of the entityid
- the instance identifier
- a fully initialized entity
getEntityName
public String getEntityName(Object object)
Get the entity name for a persistent or transient instance
- getEntityName in interface Interceptor
object
- an entity instance
instantiate
public Object instantiate(String entityName,
EntityMode entityMode,
Serializable id)
Instantiate 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.
- instantiate in interface Interceptor
entityName
- the name of the entityentityMode
- The type of entity instance to be returned.id
- the identifier of the new instance
- an instance of the class, or null to choose default behaviour
isTransient
public Boolean isTransient(Object entity)
Called 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
- isTransient in interface Interceptor
entity
- a transient or detached entity
- Boolean or null to choose default behaviour
onDelete
public void onDelete(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types)
Called before an object is deleted. It is not recommended that the interceptor modify the state.
- onDelete in interface Interceptor
onFlushDirty
public 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. 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.
- onFlushDirty in interface Interceptor
- true if the user modified the currentState in any way.
onLoad
public boolean onLoad(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types)
Called 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.
- onLoad in interface Interceptor
- true if the user modified the state in any way.
onPrepareStatement
public String onPrepareStatement(String sql)
Called when sql string is being prepared.
- onPrepareStatement in interface Interceptor
onSave
public boolean onSave(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types)
Called 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.
- onSave in interface Interceptor
- true if the user modified the state in any way.
postFlush
public 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.
- postFlush in interface Interceptor
preFlush
public void preFlush(Iterator entities)
Called before a flush
- preFlush in interface Interceptor