-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
findLastChangeRevision doesn't return last revision if two revisions with exactly the same timestamp exist #3579
Comments
Actually, shouldn't the retrieval sort by |
Hibernates documentation isn't overly clear of the semantics of the two properties. So it does indeed seem that the I'll fix that. |
Timestamps might not be unique, but the revision number "should form a strictly-increasing sequence of numbers". See https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/envers/RevisionNumber.html Closes #3579
Timestamps might not be unique, but the revision number "should form a strictly-increasing sequence of numbers". See https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/envers/RevisionNumber.html Closes #3579
We have a regression here, as revision numbers are in fact not always sequential (at least not in a multi-node environment), because of the pre-allocation of Hibernate sequence numbers. The 'order by' should probably be composed of timestamp AND rev in order to handle the issue of exactly the same timestamps. |
While running automated tests I ran into an issue with RevisionRepository.findLastChangeRevision.
If two revisions with exactly the same timestamp exist findLastChangeRevision does not necessarily return the revision with the highest revision number (which is what I would expect).
If my revinfo table has the following content findLastChangeRevision for the associated audited entity actually returns the revision with id 1 and not the one with id 2.
id,timestamp
1,2024-08-13 08:49:48.501000
2,2024-08-13 08:49:48.501000
In the implementation the revisions are ordered based on revisionProperty("timestamp") and the ID is not taken into account.
spring-data-jpa/spring-data-envers/src/main/java/org/springframework/data/envers/repository/support/EnversRevisionRepositoryImpl.java
Line 96 in a44bca8
I am aware that this is an edge case and that it's way more likely to run into it in artificial scenarios but it's also not impossible to cause issues for production code.
The text was updated successfully, but these errors were encountered: