Currently if a user wish wishes to get the current revision number and store it in an entity, it involves: {code} final AuditReader reader = AuditReaderFactory.get( session ); final DefaultRevisionEntity revisionEntity = reader.getCurrentRevision( DefaultRevisionEntity.class, true ); myEntity.setRevisionNumber( revisionEntity.getRevisionNumber() ); {code} The {{AuditReader#getCurrentRevision}} method is currently deprecated as of 5.2 and is scheduled to be removed as a part of Hibernate Envers 6. The {{RevisionListener}} interface works for situations where users need to inject values into the revision entity before its persisted but doesn't work for situations where users may need to obtain the revision number for some business purpose.
I propose we continue with the removal of {{#getCurrentRevision}} but look at offering an implementation of the {{AnnotationValueGeneration}} contract for the revision number where an entity mapping can designate a field to be populated by the revision number using {{GeenrationTiming.ALWAYS}}.
An example of how the mapping might look: {code} @RevisionNumberColumn private int revisionNumber {code} |
|