Typically, when you set a global setting such as the "org.hibernate.envers.audit_table_suffix" property, you can override the value at the class (or field) level. This is not the case with the "org.hibernate.envers.global_with_modified_flag" property; if it is set to false, it will never write modified flags even if fields are annotated like so; @Audited(withModifiedFlag = true) private EnrollmentStatus status;
I have attached a basic project where you can turn the flags on/off easily to see this issue.
To test this issue; -Install the database -Open "Config.java" and comment out the global property. -Start "Application.java" -Navigate to "localhost:8080/test". -Navigate to "localhost:8080/test" again, the first one would create your initial record, the second is an update. Any subsequent requests are updates and the status field will be modified. -Check the enrollment2_history table and observe that the modified field is being set properly. -Now uncomment the global property, and re-run the test case. You'll noticed that the modified flag is never changed to true whether the annotation is on the class level or the field level.
One thing to mention, the example project is very dirty as I was using it to diagnose this problem and it is hacked together and stripped of PII. |
|