Manuel Garcia de Vinuesa (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNTNhZDdhMjU4...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16881?atlOrigin=eyJpIjoiNTNhZD...
) HHH-16881 (
https://hibernate.atlassian.net/browse/HHH-16881?atlOrigin=eyJpIjoiNTNhZD...
) Envers RevisionListener is not created when Hibernate CDI Extensions is enabled (
https://hibernate.atlassian.net/browse/HHH-16881?atlOrigin=eyJpIjoiNTNhZD...
)
Change By: Manuel Garcia de Vinuesa (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
From Hibernate 6.2 it is mandatory enabled CDI extensions to work with Spring Container,
this is included in Spring 3.1 in the class {{HibernateJpaVendorAdapter}} (spring-orm).
!image-20230703-065313.png|width=526,height=65!
The problem it is in the class {{DefaultRevisionInfoGenerator}} (hibernate-envers) when
the method {{resolveRevisionListenerBean}}. The condition {{Helper.allowExtensionsInCdi(
serviceRegistry )}}should be negated to allow use Spring Container.
{code:java}private ManagedBean<? extends RevisionListener>
resolveRevisionListenerBean(
Class<? extends RevisionListener> listenerClass,
ServiceRegistry serviceRegistry) {
if ( !listenerClass.equals( RevisionListener.class ) ) {
if ( Helper.allowExtensionsInCdi( serviceRegistry ) ) {
return new ProvidedInstanceManagedBeanImpl<>(
FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( listenerClass )
);
}
return serviceRegistry.getService( ManagedBeanRegistry.class ).getBean( listenerClass );
}
return null;
}
{code}
To reproduce you can use my your demo (I just forked) to test it,
[mgvinuesa/hibernate-envers-spring: A demo of how to wire Spring Framework 5.1+ to inject
beans into Hibernate Envers RevisionListener
(
github.com)|https://github.com/mgvinuesa/hibernate-envers-spring]
If you change the spring boot version to 3.0, everything works properly, but when it is
updated to 3.1, the RevisionListener does not work properly and you could see in the log
the following message:
{noformat}MyService was not injected.{noformat}
(
https://hibernate.atlassian.net/browse/HHH-16881#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16881#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100228- sha1:e911e2c )