We're updating the issue view to help you get more done. 

Installing an Interceptor in an Integrator is broken

Description

Situation in Hibernate 5

The test case attached to this issue uses MyIntegrator to install an interceptor using SessionFactoryBuilder.applyInterceptor.

1 2 3 public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { metadata.getSessionFactoryBuilder().applyInterceptor(new GlobalInterceptor()); }

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

Situation in Hibernate 4

Using Hiberante 4.3 is was possible to install an interceptor using Configuration.setInterceptor.

1 2 3 public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { configuration.setInterceptor(new GlobalInterceptor()); }

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

Environment

None

Status

Assignee

Unassigned

Reporter

Christoph Keimel

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

4.3.7

Components

Affects versions

5.2.10
5.0.10

Priority

Critical