Steve,
I think he's refering to the one-line example in section 13.1. He's missing the point that the line shown is part of the overal configuration and can't be executed on it's own and separate from the overall SessionFactory configuration.
The following code is from
http://www.hibernate.org/42.html with the exception of the single change to include your interceptor.
Code:
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().setInterceptor(new YourInterceptor()).configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
sessionFactory = new Configuration()
.setInterceptor(new YourInterceptor()).configure().buildSessionFactory();