Hibernate3 Learning Notes (23) | Advanced characteristics (II.)

Source: Internet
Author: User
Tags flush object object

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);


}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.