hibernate/hibernate-orm · error · IllegalArgumentException

scale has no meaning for SQL time or timestamp types

Error message

scale has no meaning for SQL time or timestamp types

What it means

Guard in Dialect#registerColumnType/precision handling: a non-null scale was supplied (e.g. via @Column(scale=...)) for a SqlTypes.TIME/TIMESTAMP-family column. SQL time and timestamp types have no user-settable scale in this sense, so the dialect rejects the mapping at registration time rather than silently ignoring the scale.

Solutions

  1. Remove the scale attribute from the temporal column mapping.
  2. Use precision instead of scale for temporal types.
Defensive patterns

Strategy: validation

When it happens

Trigger: Triggered when the application calls a Hibernate dialect feature that the configured database dialect cannot provide: scale has no meaning for SQL time or timestamp types.

Common situations: Common when running against a database whose dialect lacks this capability, when a mapping or HQL/Criteria query requests unsupported functionality, or when the wrong dialect is configured for the database in use. Error: scale has no meaning for SQL time or timestamp types.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/e0965627a2c4c2b1. Report an issue: GitHub.

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java:6053

						throw new IllegalArgumentException("scale has no meaning for SQL floating point types");
					}
					// but if the user explicitly specifies the precision, we need to convert it:
					if ( precision != null ) {
						// convert from base 10 (as specified in @Column) to base 2 (as specified by SQL)
						// using the magic of high school math: log_2(10^n) = n*log_2(10) = n*ln(10)/ln(2)
						precision = (int) ceil( precision * LOG_BASE2OF10 );
					}
					break;
				case SqlTypes.TIME:
				case SqlTypes.TIME_WITH_TIMEZONE:
				case SqlTypes.TIME_UTC:
				case SqlTypes.TIMESTAMP:
				case SqlTypes.TIMESTAMP_WITH_TIMEZONE:
				case SqlTypes.TIMESTAMP_UTC:
					length = null;
					size.setPrecision( javaType.getDefaultSqlPrecision( Dialect.this, jdbcType ) );
					if ( scale != null && scale != 0 ) {
						throw new IllegalArgumentException("scale has no meaning for SQL time or timestamp types");
					}
					break;
				case SqlTypes.NUMERIC:
				case SqlTypes.DECIMAL:
				case SqlTypes.INTERVAL_SECOND:
					size.setPrecision( javaType.getDefaultSqlPrecision( Dialect.this, jdbcType ) );
					size.setScale( javaType.getDefaultSqlScale( Dialect.this, jdbcType ) );
					break;
			}

			if ( precision != null ) {
				size.setPrecision( precision );
			}
			if ( scale != null ) {
				size.setScale( scale );
			}
			if ( length != null ) {
				size.setLength( length );

View on GitHub (pinned to fad1729dce)