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.

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.

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

Activity

Show:
Christoph Keimel
April 1, 2019, 10:35 AM

Workaround: Instead of using an Integrator it is possible to hook the Interceptor in the persistence.xml using:
<property name="hibernate.session_factory.interceptor" value="de.emsw.gosa.hibernate.integrator.GosaInterceptor"/>

Nathan Xu
December 23, 2019, 4:13 AM

Confirmed the bug is not present for v5.4.10

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

Priority

Critical
Configure