|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Interceptor
Allows user code to inspect and/or change property values.
Inspection occurs before property values are written and after they are read
from the database.
There might be a single instance of Interceptor for a SessionFactory, or a new instance
might be specified for each Session. Whichever approach is used, the interceptor must be
serializable if the Session is to be serializable. This means that SessionFactory-scoped
interceptors should implement readResolve().
The Session may not be invoked from a callback (nor may a callback cause a collection or proxy to
be lazily initialized).
Instead of implementing this interface directly, it is usually better to extend EmptyInterceptor
and override only the callback methods of interest.
SessionFactory.openSession(Interceptor)
,
Configuration.setInterceptor(Interceptor)
,
EmptyInterceptor
Method Summary | |
---|---|
void |
afterTransactionBegin(Transaction tx)
Called when a Hibernate transaction is begun via the Hibernate Transaction 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 flush(). |
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 |
Method Detail |
---|
boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException
CallbackException
boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) throws CallbackException
CallbackException
boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException
CallbackException
void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException
CallbackException
void onCollectionRecreate(Object collection, Serializable key) throws CallbackException
CallbackException
void onCollectionRemove(Object collection, Serializable key) throws CallbackException
CallbackException
void onCollectionUpdate(Object collection, Serializable key) throws CallbackException
CallbackException
void preFlush(Iterator entities) throws CallbackException
CallbackException
void postFlush(Iterator entities) throws CallbackException
CallbackException
Boolean isTransient(Object entity)
entity
- a transient or detached entity
int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types)
entity
- a persistent entity
Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException
entityName
- the name of the entityentityMode
- The type of entity instance to be returned.id
- the identifier of the new instance
CallbackException
String getEntityName(Object object) throws CallbackException
object
- an entity instance
CallbackException
Object getEntity(String entityName, Serializable id) throws CallbackException
entityName
- the name of the entityid
- the instance identifier
CallbackException
void afterTransactionBegin(Transaction tx)
void beforeTransactionCompletion(Transaction tx)
void afterTransactionCompletion(Transaction tx)
String onPrepareStatement(String sql)
sql
- sql to be prepared
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |