4.Interceptor Interface:
You can load a custom interceptor when the session is opened, and the interceptor will call the corresponding method before the corresponding action occurs by allowing you to define the interceptor as the Interceptor interface, which is defined as follows:
Interceptor.java
package org.hibernate;
import java.io.Serializable;
import Java.util.Iterator;
import Org.hibernate.type.Type;
public interface Interceptor {
//Load object before executing
Public
Boolean onLoad (Object entity, Serializable ID, object[] state, string[] propertynames, type[] types)
throws Callbackexception;
//Flush, if dirty data is found, this method is executed
Public
Boolean onflushdirty (Object entity, Serializable ID, object[] currentstate, object[] previousstate,
string[] propertynames, type[] types throws callbackexception;
//Storage of objects before executing
Public
Boolean onSave (Object entity, Serializable ID, object[] state, string[] propertynames, type[] types)
throws Callbackexception;
//Delete object before executing
Public
void OnDelete (Object entity, Serializable ID, object[] state, string[] propertynames, type[] types)
throws Callbackexception;
//Flush prior to execution
public void Preflush (iterator entities) throws callbackexception;
//execute
after flush
public void Postflush (iterator entities) throws callbackexception;
//Determine if the incoming object is a transient state
public Boolean istransient (Object entity);
//Flush before calling this method to determine the Dirty data
//Returns the Dirty Data property index or null-mining default behavior
Public
Int[] Finddirty (Object entity, Serializable ID, object[] currentstate, object[] previousstate,
string[] propertynames, type[] types);
//Manually establishes the entity object, and if NULL is returned, the instance is established using the default constructor
public Object Instantiate (String entityname, Entitymode Entitymode, Serializable ID)
throws Callbackexception;
//Returns the entity name
public String Getentityname (Object object) throws Callbackexception;
//Get entity Objects
public Object getentity (String entityname, Serializable id) throws callbackexception;
//BeginTransaction () after the execution of
public void Aftertransactionbegin (Transaction tx);
//Execute
before the transaction is completed
public void Beforetransactioncompletion (Transaction tx);
//Execute
after the transaction is completed
public void Aftertransactioncompletion (Transaction tx);
}