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

EnversRevisionRepositoryImpl::findRevision change in behaviour #333

Open
neil-ca-moore opened this issue Dec 20, 2021 · 5 comments
Open
Labels
status: feedback-provided Feedback has been provided

Comments

@neil-ca-moore
Copy link

neil-ca-moore commented Dec 20, 2021

Somewhere between 2.1.17 and 2.5.6, the behaviour of this function has changed. I can work on a minimal repro case if required, but before I go to that effort I just want to check whether anybody is aware of this (I couldn't find it in the release notes)? Also it might be a different project that the bug should be filed against?

Please let me know next steps?

Thanks.

Scenario:

Entity E_1 and E_2 both annotated with @Audited
Create entity E_1, at time T_1 at revision 1.
Create another entity E_2, at time T_2 at revision 2.
Postgres DB

Steps:
Call org.springframework.data.envers.repository.support.EnversRevisionRepositoryImpl#findRevision with arguments

ID =
revisionNumber = 2

Result at spring-data-envers 2.1.17:

Result E_1 at revision 1

Result at spring-data-envers 2.5.6:

Optional.empty()

Conclusion:

It seems like the behaviour changed from returning the most recent version at that revision or earlier, to returning only the specific revision requested?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 20, 2021
@schauder
Copy link
Contributor

Yes, please provide a reproducer.

@schauder schauder added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 21, 2021
@neil-ca-moore
Copy link
Author

@schauder I wrote a test that fails in more recent versions. I used 2.5.6 because that's where I found it.

I also wrote the same test against an earlier version (2.1.17), that test passes.

So it seems there has been a change of behaviour, whether in the spring-data-envers project or maybe a dependency.

Wondering which is the correct behaviour?

For background, we are using this code to achieve fetching by date. By using AuditReader to get a revision number for a date, then fetching that revision using RevisionRepository.

There is already a request for that to be implemented directly: #301.

Thank you for your help.

@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 Dec 21, 2021
@neil-ca-moore
Copy link
Author

@schauder Wondering your thoughts on this, please?

@neil-ca-moore
Copy link
Author

Wondering what will happen with this issue, please? @christophstrobl you have been active on the project recently.

@em2e
Copy link

em2e commented Feb 10, 2023

This caused a problem for me too! The behavior was changed in 2.3.0.RC2.
Before this change the envers AuditReader.findRevision method was used, and it finds the most recent version up to the given revision number (less than or equal to). After the change the code use it's own query:
createBaseQuery(id).add(AuditEntity.revisionNumber().eq(revisionNumber))
so it finds only the exact match.
I thing the envers original logic is what we expect here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided
Projects
None yet
Development

No branches or pull requests

4 participants