org.hibernate.envers.boot.internal.LegacyModifiedColumnNamingStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-envers-jakarta Show documentation
Show all versions of hibernate-envers-jakarta Show documentation
Hibernate's entity version (audit/history) support Jakarta edition
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.envers.boot.internal;
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.mapping.Value;
import org.dom4j.Element;
/**
* A {@link ModifiedColumnNamingStrategy} that adds modified columns with the following rules:
*
* - If an audit annotation modified column name is supplied, use it directly with no suffix.
* - If no audit annotation modified column name is present, use the property name appended with suffix.
*
*
* This is the default Envers modified column naming behavior.
*
* @author Chris Cranford
* @since 5.4.7
*/
public class LegacyModifiedColumnNamingStrategy implements ModifiedColumnNamingStrategy {
@Override
public void addModifiedColumns(
GlobalConfiguration globalCfg,
Value value,
Element parent,
PropertyAuditingData propertyAuditingData) {
final String columnName;
if ( propertyAuditingData.isModifiedFlagNameExplicitlySpecified() ) {
columnName = propertyAuditingData.getExplicitModifiedFlagName();
}
else {
columnName = propertyAuditingData.getModifiedFlagName();
}
MetadataTools.addModifiedFlagPropertyWithColumn(
parent,
propertyAuditingData.getName(),
globalCfg.getModifiedFlagSuffix(),
propertyAuditingData.getModifiedFlagName(),
columnName
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy