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 class CalendarDateJavaType extends AbstractTemporalJavaType<Calendar> {
@Override
public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) {
return dialect.getDefaultTimestampPrecision();
return 0;
}
}

View File

@ -144,6 +144,9 @@ public class CalendarTimeJavaType extends AbstractTemporalJavaType<Calendar> {
@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 class DateJavaType extends AbstractTemporalJavaType<Date> implements Vers
@Override
public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) {
// this "Date" is really a timestamp
return dialect.getDefaultTimestampPrecision();
}

View File

@ -273,7 +273,10 @@ public class JdbcTimeJavaType extends AbstractTemporalJavaType<Date> {
@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 class LocalTimeJavaType extends AbstractTemporalJavaType<LocalTime> {
@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 @@ public class OffsetTimeJavaType extends AbstractTemporalJavaType<OffsetTime> {
@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 class DdlTypeRegistry implements Serializable {
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: