hibernate/hibernate-orm · error · SemanticException

Inconvertible unit " + this

Error message

Inconvertible unit " + this

What it means

Error "Inconvertible unit " + this" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/common/TemporalUnit.java:259

			case WEEK:
				factor *= 7;
				//conversion to nanos:
			case DAY:
				factor *= 24;
			case HOUR:
				factor *= 60;
			case MINUTE:
				factor *= 60;
			case EPOCH:
			case SECOND:
				factor *= 1_000_000_000;
			case NANOSECOND:
				break;
			case NATIVE:
				factor *= dialect.getFractionalSecondPrecisionInNanos();
				break;
			default:
				throw new SemanticException("Inconvertible unit " + this);
		}
		return factor;
	}

	/**
	 * Obtain a fragment of SQL that can be used to perform
	 * a unit conversion. If the normalization factor is
	 * very large, represent it using exponential form so
	 * as to minimize the noise the generated SQL.
	 *
	 * @param factor the conversion factor
	 * @return a string to inject into the SQL expression
	 */
	private static String factorAsString(long factor) {
		String string = String.valueOf(factor);
		int len = string.length();
		int chop;
		for (chop = len; chop>0 && string.charAt(chop-1)=='0'; chop--) {}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use a temporal unit with a fixed duration for conversion.
  2. Handle month/year units separately in application code.

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/16133ebbc07e922f. Report an issue: GitHub.