HHH-10398 Allow MOD column naming to be driven by a strategy
* Fixed javadoc comments * Various code suggested code changes from review
This commit is contained in:
parent
f78877a607
commit
b606759e61
|
@ -10,7 +10,6 @@ import org.hibernate.envers.boot.spi.ModifiedColumnNamingStrategy;
|
|||
import org.hibernate.envers.configuration.internal.GlobalConfiguration;
|
||||
import org.hibernate.envers.configuration.internal.metadata.MetadataTools;
|
||||
import org.hibernate.envers.configuration.internal.metadata.reader.PropertyAuditingData;
|
||||
import org.hibernate.envers.internal.tools.StringTools;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Selectable;
|
||||
import org.hibernate.mapping.Value;
|
||||
|
@ -30,9 +29,9 @@ import org.dom4j.Element;
|
|||
* </ul>
|
||||
*
|
||||
* @author Chris Cranford
|
||||
* @since 5.4.6
|
||||
* @since 5.4.7
|
||||
*/
|
||||
public class ImprovedModifiedColumnNamingStrategy implements ModifiedColumnNamingStrategy {
|
||||
public class ImprovedModifiedColumnNamingStrategy extends LegacyModifiedColumnNamingStrategy {
|
||||
@Override
|
||||
public void addModifiedColumns(
|
||||
GlobalConfiguration globalCfg,
|
||||
|
@ -48,7 +47,7 @@ public class ImprovedModifiedColumnNamingStrategy implements ModifiedColumnNamin
|
|||
Selectable selectable = value.getColumnIterator().next();
|
||||
if ( selectable instanceof Column ) {
|
||||
// This should not be applied for formulas
|
||||
String columnName = propertyAuditingData.getModifiedFlagName();
|
||||
final String columnName;
|
||||
if ( !propertyAuditingData.isModifiedFlagNameExplicitlySpecified() ) {
|
||||
columnName = ( (Column) selectable ).getName() + globalCfg.getModifiedFlagSuffix();
|
||||
}
|
||||
|
@ -70,11 +69,6 @@ public class ImprovedModifiedColumnNamingStrategy implements ModifiedColumnNamin
|
|||
}
|
||||
|
||||
// Default legacy behavior
|
||||
MetadataTools.addModifiedFlagProperty(
|
||||
parent,
|
||||
propertyAuditingData.getName(),
|
||||
globalCfg.getModifiedFlagSuffix(),
|
||||
propertyAuditingData.getModifiedFlagName()
|
||||
);
|
||||
super.addModifiedColumns( globalCfg, value, parent, propertyAuditingData );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.dom4j.Element;
|
|||
* This is the default Envers modified column naming behavior.
|
||||
*
|
||||
* @author Chris Cranford
|
||||
* @since 5.4.6
|
||||
* @since 5.4.7
|
||||
*/
|
||||
public class LegacyModifiedColumnNamingStrategy implements ModifiedColumnNamingStrategy {
|
||||
@Override
|
||||
|
@ -33,10 +33,13 @@ public class LegacyModifiedColumnNamingStrategy implements ModifiedColumnNamingS
|
|||
Value value,
|
||||
Element parent,
|
||||
PropertyAuditingData propertyAuditingData) {
|
||||
String columnName = propertyAuditingData.getModifiedFlagName();
|
||||
final String columnName;
|
||||
if ( propertyAuditingData.isModifiedFlagNameExplicitlySpecified() ) {
|
||||
columnName = propertyAuditingData.getExplicitModifiedFlagName();
|
||||
}
|
||||
else {
|
||||
columnName = propertyAuditingData.getModifiedFlagName();
|
||||
}
|
||||
MetadataTools.addModifiedFlagProperty(
|
||||
parent,
|
||||
propertyAuditingData.getName(),
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.dom4j.Element;
|
|||
* Defines a naming strategy for applying modified columns to the audited entity metamodel.
|
||||
*
|
||||
* @author Chris Cranford
|
||||
* @since 5.4.6
|
||||
* @since 5.4.7
|
||||
*/
|
||||
@Incubating
|
||||
public interface ModifiedColumnNamingStrategy {
|
||||
|
|
|
@ -139,7 +139,7 @@ public interface EnversSettings {
|
|||
*
|
||||
* Defaults to {@link org.hibernate.envers.boot.internal.LegacyModifiedColumnNamingStrategy}.
|
||||
*
|
||||
* @since 5.4.6
|
||||
* @since 5.4.7
|
||||
*/
|
||||
String MODIFIED_COLUMN_NAMING_STRATEGY = "org.hibernate.envers.modified_column_naming_strategy";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue