HHH-17576 inappropriate use of getDefaultTimestampPrecision() as default precision

This default is only appropriate for timestamps (hence the name) and should not be
used for dates or plain times.
This commit is contained in:
Gavin King 2023-12-18 20:52:37 +01:00
parent 6d4002bd97
commit 6d64e854e2
7 changed files with 18 additions and 8 deletions

View File

@ -142,6 +142,6 @@ public boolean isWider(JavaType<?> javaType) {
@Override
public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) {
return dialect.getDefaultTimestampPrecision();
return 0;
}
}

View File

@ -144,6 +144,9 @@ public boolean isWider(JavaType<?> javaType) {
@Override
public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) {
return dialect.getDefaultTimestampPrecision();
// times represent repeating events - they
// almost never come equipped with seconds,
// let alone fractional seconds!
return 0;
}
}

View File

@ -52,6 +52,7 @@ public TemporalType getPrecision() {
@Override
public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) {
// this "Date" is really a timestamp
return dialect.getDefaultTimestampPrecision();
}

View File

@ -273,7 +273,10 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
@Override
public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) {
return dialect.getDefaultTimestampPrecision();
// times represent repeating events - they
// almost never come equipped with seconds,
// let alone fractional seconds!
return 0;
}
@Override

View File

@ -189,7 +189,10 @@ public boolean isWider(JavaType<?> javaType) {
@Override
public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) {
return dialect.getDefaultTimestampPrecision();
// times represent repeating events - they
// almost never come equipped with seconds,
// let alone fractional seconds!
return 0;
}
}

View File

@ -251,7 +251,10 @@ private static ZoneOffset getCurrentSystemOffset() {
@Override
public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) {
return dialect.getDefaultTimestampPrecision();
// times represent repeating events - they
// almost never come equipped with seconds,
// let alone fractional seconds!
return 0;
}
}

View File

@ -162,9 +162,6 @@ public String getTypeName(int typeCode, Dialect dialect) {
return getTypeName( typeCode, Size.precision( dialect.getFloatPrecision() ) );
case SqlTypes.DOUBLE:
return getTypeName( typeCode, Size.precision( dialect.getDoublePrecision() ) );
case SqlTypes.TIME:
case SqlTypes.TIME_WITH_TIMEZONE:
case SqlTypes.TIME_UTC:
case SqlTypes.TIMESTAMP:
case SqlTypes.TIMESTAMP_WITH_TIMEZONE:
case SqlTypes.TIMESTAMP_UTC: