| Modified column naming happens based on a deterministic order of values. Currently, we look for whether an @Audited annotation exists for that property and if the modifiedColumnName attribute is provided. If the annotation is provided and the attribute is non-empty, the column name will be taken as a literal value, meaning we won't append the suffix value. However, if that attribute isn't provided or is empty, we'll take the property name as defined in the class and append the suffix value to it when defining the database column in the schema. As a work around, you could easily amend your field's annotations to include the following:
@Audited(modifiedColumnName = "customer_account_id_mod")
@Audited(withModifiedFlag = true, modifiedColumnName = "customer_account_id_mod")
For 6.0, I'll be adding the following new configuration setting: org.hibernate.envers.modified_flag_naming_strategy The DefaultModifiedFlagNamingStrategy will continue to use the existing logic we have where we prioritize the literal modifiedColumnName value with the fallback of using the property name appended by the configured suffix value. A new ImprovedModifiedFlagNamingStrategy will alter the behavior slightly such that we will prioritize the naming as follows:
- Use @Audited(modifiedColumnName="...") first if provided. The column name will be taken literal based on the annotation value. (just like the default strategy)
- Use @Column or @JoinColumn annotation name attributes if provided. The column name will be appended with the configured Envers settings suffix.
- Use the property name appended with the configured Envers settings suffix (just like the default strategy).
This should help simplify the necessary configuration for users who want to use this feature but prefer the column names to differ simply by the configured suffix without having to be overly explicit in their annotation binding configurations. |