Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityTrackingRevisionListener is not spring managed since 3.1.1 #36511

Closed
Drezir opened this issue Jul 24, 2023 · 5 comments
Closed

EntityTrackingRevisionListener is not spring managed since 3.1.1 #36511

Drezir opened this issue Jul 24, 2023 · 5 comments
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@Drezir
Copy link

Drezir commented Jul 24, 2023

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 24, 2023
@wilkinsona
Copy link
Member

This may be related to spring-projects/spring-framework#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.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jul 24, 2023
@Drezir
Copy link
Author

Drezir commented Jul 24, 2023

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

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

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 24, 2023
@1dEraNCeSIv0
Copy link

1dEraNCeSIv0 commented Jul 24, 2023

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

@wilkinsona
Copy link
Member

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

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Jul 24, 2023
@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Jul 24, 2023
@Drezir
Copy link
Author

Drezir commented Jul 25, 2023

Thank you for clarifying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants