hibernate/hibernate-orm · error · SemanticException
Illegal unit for timestamp_add(): ${unit}
Error message
Illegal unit for timestamp_add(): ${unit} What it means
Error "Illegal unit for timestamp_add(): ${unit}" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java:954
case DAY_OF_MONTH:
return "day";
case DAY_OF_WEEK:
return "dayofweek";
case DAY_OF_YEAR:
return "dayofyear";
default:
return super.translateExtractField(unit);
}
}
@Override
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType) {
if ( temporalType == TemporalType.TIMESTAMP || temporalType == TemporalType.TIME ) {
switch ( unit ) {
case YEAR:
case QUARTER:
case MONTH:
throw new SemanticException( "Illegal unit for timestamp_add(): " + unit );
case WEEK:
return "timestamp_add(?3, interval cast(?2 * 7 as int64) day)";
case SECOND:
return "timestamp_add(?3, interval cast(?2 * 1000000000 as int64) nanosecond)";
default:
return "timestamp_add(?3, interval cast(?2 as int64) ?1)";
}
}
else {
switch ( unit ) {
case NANOSECOND:
case SECOND:
case MINUTE:
case HOUR:
case NATIVE:
throw new SemanticException( "Illegal unit for date_add(): " + unit );
default:
return "date_add(?3, interval cast(?2 as int64) ?1)";View on GitHub (pinned to fad1729dce)
Solutions
- Use a unit supported by Spanner (e.g. DAY, HOUR, MINUTE, SECOND).
When it happens
Trigger: Triggered when the application calls a Hibernate dialect feature that the configured database dialect cannot provide: Illegal unit for timestamp_add(): $the given unit.
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: Illegal unit for timestamp_add(): $the given unit.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/5c7a9946bd3535c6.
Report an issue: GitHub.