We are using hibernate envers with custom revision table created by EntityTrackingRevisionListener.

@Slf4j
@RequiredArgsConstructor
public class CustomRevisionListener implements EntityTrackingRevisionListener {

    private final CoreSecurityService coreSecurityService;
......
}

Usage:

@Entity
@RevisionEntity(CustomRevisionListener.class)
@Table(name = "core_revision_info")
@Getter
@Setter
public class CoreRevisionEntity extends DefaultRevisionEntity {
}

In spring boot 3.1.0, somehow dependency resolution works and inject spring managed bean CoreSecurityService so it is not null.

Since 3.1.1 it does not work and our coreSecurityService is null.

It seems to me that we have took advantage of some bug because I cannot find how spring could inject beans into hibernate managed objects.

Comment From: wilkinsona

This may be related to https://github.com/spring-projects/spring-framework/issues/30545, https://hibernate.atlassian.net/browse/HHH-16069, and https://hibernate.atlassian.net/browse/HHH-16935 but it's hard to be certain without a reproducer. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: Drezir

Projects here. They are failing on DDL but it still reproduces the error.

not-working-3.1.1.zip working-3.1.0.zip

Comment From: 1dEraNCeSIv0

Seems like the same issue as the one I reported. Note that there's a workaround of providing the spring property spring.jpa.properties.hibernate.cdi.extensions=false 🙃

Once hibernate applies their fix you'll have to set the property to true however

Edit: The below should demonstrate that it's the same issue, causing the same error without using the EntityTrackingRevisionListener in particular hibernate-envers-injection.zip

Comment From: wilkinsona

Thanks, @1dEraNCeSIv0, that confirms my suspicion. This will have to be addressed in Hibernate.

Comment From: Drezir

Thank you for clarifying