My Java applications uses Hibernate with a SessionFactory-scoped interceptor in order to change data before storing in the database.
myConfiguration.setInterceptor(new MyInterceptor());
SessionFactory sf = myConfiguration.buildSessionFactory();
With the release 4.0 of hibernate they changed the concept of using the class Configuration.
So my new approach is:
final ServiceRegistryBuilder srb = new ServiceRegistryBuilder();
srb.configure(...); // Hibernate configuration
final ServiceRegistry sr = srb.buildServiceRegistry();
final MetadataSources mds = new MetadataSources(sr);
mds.add...(); // All the meta data configurations
final Metadata md = mds.buildMetadata();
SessionFactory sf = md.buildSessionFactory();
I have not found a point where to set the interceptor with this new approach.
Any recommendations on how to set a SessionFactory-scoped interceptor?
What about: