|
When the property org.hibernate.envers.revison_on_collection_change is set to false, and an entity contains an @Element collection, for example:
@ElementCollection private List<String> listValues = new ArrayList<String>();
Hibernate Envers creates an audit table corresponding to the table used to store the ElementCollection values. However the table is never used.
This functionality seems incorrect based on the published documentation and the inferred intent of this configuration property.
According to the documentation, the property org.hibernate.envers.revison_on_collection_change "determines if a revision should be generated if a relation field that is not owned changes." I presume that the reasoning behind providing this setting is that a non-owned field will be audited by some other mechanism, for example an entity on the many side of a one-many relationship will be audited independent of its relationship in the collection. The setting is thus useful for eliminating the arguably redundant auditing record on the one side of the relationship, since this can be logically inferred from the audit data for the many-side entity.
However in the case of an @ElementCollection of simple or embedded types, there is no independent entity where the audit can occur, so the effect of the setting is basically to competely remove all auditing for the collection table without any other way to accomplish this auditing (short of changing the configuration setting in question). Thus it would seem more correct for Envers to have normal auditing behavior here rather than suppressing auditing, even when revison_on_collection_change is false.
|