Java Reference
In-Depth Information
protected String getName() {
return name;
}
protected void setName(String name) {
this.name = name;
}
protected String getSeat() {
return seat;
}
protected void setSeat(String seat) {
this.seat = seat;
}
private String seat;
private String name;
}
Interceptors have to override the org.hibernate.Interceptor interface. You can set a
global interceptor for the configuration (see Listing A-25), or you can apply interceptors on a
per-session basis. You have to install the interceptor programmatically—there is no syntax for
specifying this in the Hibernate configuration file.
Listing A-25. Installing a Global Interceptor
package com.hibernatebook.advanced.events;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class MailingExample {
public static void main(String[] argv) {
Configuration config = new Configuration();
// Apply this interceptor at a global level...
config.setInterceptor(new BookingInterceptor());
SessionFactory factory = config.configure().buildSessionFactory();
Session session = factory.openSession();
// A local interceptor could alternatively
// be applied here:
// session.setInterceptor(new BookingInterceptor());
Search WWH ::




Custom Search