Мои Java-приложения используют Hibernate с перехватчиком SessionFactory для изменения данных перед сохранением в базе данных.
myConfiguration.setInterceptor(new MyInterceptor());
SessionFactory sf = myConfiguration.buildSessionFactory();
С выпуском 4.0 спящего режима они изменили концепцию использования класса Configuration.
Итак, мой новый подход:
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();
Я не нашел точку, где установить перехватчик с этим новым подходом. Любые рекомендации о том, как установить перехватчик с областью действия SessionFactory?