| While I wait for you to supply the query, I am suspecting you might be using the AuditReader#find methods. Those methods are currently designed to allow the caller to supply an instant in time (e.g. a revision number or date) and the API finds the most recent audit row for that entity-type and primary key that does not exceed the instant in time supplied. This is super helpful for situations where you need to find audit data for an unrelated entity based on another entity's revision data. For example, lets say you have EntityB and EntityA and you need to find out what EntityB looked like when EntityA was modified at X revision or on a specific date. That said you should be able to obtain the behavior you want but by using a more explicit query rather than the #find helper methods on the AuditReader interface. I suspect something like this might just work:
AuditReader auditReader = AuditReaderFactory.get( session );
List results auditReader.createQuery().forEntitiesAtRevision( YourEntity.class, entityId )
.add( AuditEntity.revisionNumber().eq( revisionNumber ) )
.getResultList();
In the above, you're explicitly controlling the outer query to only return a non-empty result-set if there is actually an entry in the REVINFO table if and only if the pair entityId, revisionNumber match a row. If it does not, you'll get no results rather than the latest entry that doesn't exceed the specified revision's instant in time. |