use of org.hibernate.boot.model.naming.ImplicitBasicColumnNameSource in project hibernate-orm by hibernate.
the class Ejb3Column method redefineColumnName.
public void redefineColumnName(String columnName, String propertyName, boolean applyNamingStrategy) {
final ObjectNameNormalizer normalizer = context.getObjectNameNormalizer();
final Database database = context.getMetadataCollector().getDatabase();
final ImplicitNamingStrategy implicitNamingStrategy = context.getBuildingOptions().getImplicitNamingStrategy();
final PhysicalNamingStrategy physicalNamingStrategy = context.getBuildingOptions().getPhysicalNamingStrategy();
if (applyNamingStrategy) {
if (StringHelper.isEmpty(columnName)) {
if (propertyName != null) {
final AttributePath attributePath = AttributePath.parse(propertyName);
Identifier implicitName = normalizer.normalizeIdentifierQuoting(implicitNamingStrategy.determineBasicColumnName(new ImplicitBasicColumnNameSource() {
@Override
public AttributePath getAttributePath() {
return attributePath;
}
@Override
public boolean isCollectionElement() {
// @Column refers to the element column
return !propertyHolder.isComponent() && !propertyHolder.isEntity();
}
@Override
public MetadataBuildingContext getBuildingContext() {
return context;
}
}));
// HHH-6005 magic
if (implicitName.getText().contains("_collection&&element_")) {
implicitName = Identifier.toIdentifier(implicitName.getText().replace("_collection&&element_", "_"), implicitName.isQuoted());
}
final Identifier physicalName = physicalNamingStrategy.toPhysicalColumnName(implicitName, database.getJdbcEnvironment());
mappingColumn.setName(physicalName.render(database.getDialect()));
}
//Do nothing otherwise
} else {
final Identifier explicitName = database.toIdentifier(columnName);
final Identifier physicalName = physicalNamingStrategy.toPhysicalColumnName(explicitName, database.getJdbcEnvironment());
mappingColumn.setName(physicalName.render(database.getDialect()));
}
} else {
if (StringHelper.isNotEmpty(columnName)) {
mappingColumn.setName(normalizer.toDatabaseIdentifierText(columnName));
}
}
}
use of org.hibernate.boot.model.naming.ImplicitBasicColumnNameSource in project hibernate-orm by hibernate.
the class Ejb3Column method addColumnBinding.
protected void addColumnBinding(SimpleValue value) {
final String logicalColumnName;
if (StringHelper.isNotEmpty(this.logicalColumnName)) {
logicalColumnName = this.logicalColumnName;
} else {
final ObjectNameNormalizer normalizer = context.getObjectNameNormalizer();
final Database database = context.getMetadataCollector().getDatabase();
final ImplicitNamingStrategy implicitNamingStrategy = context.getBuildingOptions().getImplicitNamingStrategy();
final Identifier implicitName = normalizer.normalizeIdentifierQuoting(implicitNamingStrategy.determineBasicColumnName(new ImplicitBasicColumnNameSource() {
@Override
public AttributePath getAttributePath() {
return AttributePath.parse(propertyName);
}
@Override
public boolean isCollectionElement() {
return false;
}
@Override
public MetadataBuildingContext getBuildingContext() {
return context;
}
}));
logicalColumnName = implicitName.render(database.getDialect());
}
context.getMetadataCollector().addColumnNameBinding(value.getTable(), logicalColumnName, getMappingColumn());
}
Aggregations