Hibernate Envers has a very specific configuration setting which controls whether or not the optimistic locking field annotated by the @Version annotation is tracked. The name of this configuration property is org.hibernate.envers.do_not_audit_optimistic_locking_field and by default it is true. This means that we do not audit this field. If you enable this to false, then the field will be tracked.
I do want to caution that when the field is tracked, we treat it like any other basic attribute. That means if the original value differs from the value in the persistence context when the persistence operation occurs, that will trigger an audit row insert (even if no other field’s value changed in the entity). This behavior is quite common when using LockModeType#OPTIMISTIC_FORCE_INCREMENT. But if you aren’t doing anything like this, you won’t see any difference in behavior.
Unfortunately, I changed do_not_audit_optimistic_locking_field to true, but version still null.
I observed any things - in AUD table with version column added REV and REVTYPE columns and they are filled.
In main table(table of entity) in version field version filled and correct value.
@Naros i guess that in 4 version of hibernate-envers there is no functionality for version column, because in AUD table added REV and REV_TYPE columns. In main table of my entity version column is okey, problem is occours only in AUD table
I know the option is there, see the following link:
I would need to check if the functionality is broken in 4.0.1; however if it is you’ll need to upgrade to a later version as we won’t be doing bugfixes to that legacy community version.
@Naros I am using 5.3.7 version. Changing ‘do_not_audit_optimistic_locking_field’ to false doesn’t work.
As per AuditedPropertiesReader, isDoNotAuditOptimisticLockingField’s ‘true’ value is only being checked for version. So, setting this field value to false doesn’t work. Can you please confirm if there is any latest version where this works?