fix @Column(precision=p) with TimeZoneStorageType.COLUMN

This commit is contained in:
Gavin 2022-12-07 13:44:21 +01:00 committed by Gavin King
parent cceac72a22
commit 512ad8c80d
1 changed files with 39 additions and 34 deletions

View File

@ -525,45 +525,50 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
}
private static Column createTimestampColumn(XAnnotatedElement element, String path, MetadataBuildingContext context) {
int precision;
final Column annotatedColumn = element.getAnnotation( Column.class );
if ( annotatedColumn != null ) {
return annotatedColumn;
if ( !annotatedColumn.name().isEmpty() ) {
return annotatedColumn;
}
precision = annotatedColumn.precision();
}
else {
// Base the name of the synthetic dateTime field on the name of the original attribute
final Identifier implicitName = context.getObjectNameNormalizer().normalizeIdentifierQuoting(
context.getBuildingOptions().getImplicitNamingStrategy().determineBasicColumnName(
new ImplicitBasicColumnNameSource() {
final AttributePath attributePath = AttributePath.parse(path);
@Override
public AttributePath getAttributePath() {
return attributePath;
}
@Override
public boolean isCollectionElement() {
return false;
}
@Override
public MetadataBuildingContext getBuildingContext() {
return context;
}
}
)
);
return new ColumnImpl(
implicitName.getText(),
false,
true,
true,
true,
"",
"",
0
);
precision = 0;
}
// Base the name of the synthetic dateTime field on the name of the original attribute
final Identifier implicitName = context.getObjectNameNormalizer().normalizeIdentifierQuoting(
context.getBuildingOptions().getImplicitNamingStrategy().determineBasicColumnName(
new ImplicitBasicColumnNameSource() {
final AttributePath attributePath = AttributePath.parse(path);
@Override
public AttributePath getAttributePath() {
return attributePath;
}
@Override
public boolean isCollectionElement() {
return false;
}
@Override
public MetadataBuildingContext getBuildingContext() {
return context;
}
}
)
);
return new ColumnImpl(
implicitName.getText(),
false,
true,
true,
true,
"",
"",
precision
);
}
private static Map<String, ColumnTransformer> buildColumnTransformerOverride(XAnnotatedElement element) {