hibernate/hibernate-orm · error · SemanticException
Illegal unit " + this
Error message
Illegal unit " + this
What it means
Thrown by TemporalUnit.normalized() when the enum constant has no assigned normalization family. The method maps every unit either to NANOSECOND (duration-based units) or MONTH (calendar-based units); hitting the default branch means an unlisted/unsupported unit was passed through the type hierarchy — an internal invariant violation rather than a user input error.
Solutions
- Use a supported TemporalUnit in this context.
- Check the unit against the database dialect's supported units.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: A runtime precondition of the Hibernate API is violated.
Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/8fa41a266c654134.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/query/common/TemporalUnit.java:349
* durations.
*/
public TemporalUnit normalized() {
switch (this) {
case NANOSECOND:
case NATIVE:
case HOUR:
case MINUTE:
case SECOND:
case EPOCH:
case DAY:
case WEEK:
return NANOSECOND;
case YEAR:
case QUARTER:
case MONTH:
return MONTH;
default:
throw new SemanticException("Illegal unit " + this);
}
}
@Override
public String toString() {
return super.toString().toLowerCase();
}
}
View on GitHub (pinned to fad1729dce)