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.
|
.addOrder(AuditEntity.revisionProperty("timestamp").desc()) // |
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.