h3. Situation in Hibernate 5
The test case attached to this issue uses {{MyIntegrator }} to install an interceptor using {{SessionFactoryBuilder.applyInterceptor}}.
{code:java} public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { metadata.getSessionFactoryBuilder().applyInterceptor(new GlobalInterceptor()); } {code}
Expected: * The interceptor should be used for new sessions used by the JPA entity manager * Specifically: The method {{GlobalInterceptor.onSave}} should be called when {{EntityManager.persist}} gets called
Observed: * The interceptor is not used at all when using the JPA {{EntityManager}}
h3. Situation in Hibernate 4
Using Hiberante 4.3 is was possible to install an interceptor using {{Configuration .setInterceptor}}.
{code:java} public class MyIntegrator implements Integrator { @Override public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { configuration.setInterceptor(new GlobalInterceptor()); }
... } {code}
h3. Misc
We discovered this issue while upgrading to Wildfly 10.1.0 which includes Hibernate 5.0.10. This is a critical issue from our point of view, as we have not yet discoverd another hook to install interceptors. Since we are working with the JPA {{EntityManger}} we can not use the {{Session}} API.
Link to the discussion on the forum: https://forum.hibernate.org/viewtopic.php?f=1&t=1044595&start=0&sid=5ed0e967cd91540236401053e9f66f22 |
|