hibernate/hibernate-orm · error · MappingException

Explicit JavaType [<explicitJavaType>] defined for temporal

Error message

Explicit JavaType [<explicitJavaType>] defined for temporal value must implement TemporalJavaType

What it means

Error "Explicit JavaType [<explicitJavaType>] defined for temporal value must implement TemporalJavaType" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/InferredBasicValueResolver.java:620

				temporalJavaType,
				temporalJavaType,
				explicitJdbcType,
				jdbcMapping,
				temporalJavaType.getMutabilityPlan()
		);
	}

	private static <T> @Nonnull InferredBasicValueResolution<T, T> fromTemporalExplicitJavaType(
			BasicJavaType<?> explicitJavaType,
			JdbcType explicitJdbcType,
			Function<TypeConfiguration, MutabilityPlan<?>> explicitMutabilityPlanAccess,
			JdbcTypeIndicators stdIndicators) {
		final var typeConfiguration = stdIndicators.getTypeConfiguration();
		final var basicTypeRegistry = typeConfiguration.getBasicTypeRegistry();
		final var requestedTemporalPrecision = stdIndicators.getTemporalPrecision();

		if ( !isTemporal( explicitJavaType ) ) {
			throw new MappingException( "Explicit JavaType [" + explicitJavaType +
					"] defined for temporal value must implement TemporalJavaType" );
		}

		@SuppressWarnings("unchecked")
		final var explicitTemporalJtd = (TemporalJavaType<T>) explicitJavaType;
		if ( requestedTemporalPrecision != null
				&& explicitTemporalJtd.getPrecision() != requestedTemporalPrecision ) {
			throw new MappingException(
					"Temporal precision (TemporalType) mismatch; requested precision = %s; explicit JavaType (%s) precision = %s"
							.formatted( requestedTemporalPrecision, explicitTemporalJtd, explicitTemporalJtd.getPrecision() )

			);
		}

		final var jdbcType =
				explicitJdbcType != null
						? explicitJdbcType
						: explicitTemporalJtd.getRecommendedJdbcType( stdIndicators );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use a JavaType that implements TemporalJavaType (e.g. the built-in temporal types) for this temporal attribute, or drop the explicit @JavaType.

Example fix

Use a JavaType that implements TemporalJavaType (e.g. the built-in temporal types) for this temporal attribute, or drop the explicit @JavaType.

When it happens

Trigger: An entity mapping annotation or bootstrap configuration violates a Hibernate mapping rule.

Common situations: Annotation mapping mistakes: inverse-side @Id associations, @Column on @OneToOne, unmapped association targets, mismatched @EnumeratedValue/@Temporal usage, duplicate sequence generators.


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