hibernate/hibernate-orm · error · MappingException

Incorrect use of entity type '<resolvedJavaType.getTypeName(

Error message

Incorrect use of entity type '<resolvedJavaType.getTypeName()>' (possibly due to missing association mapping annotation)

What it means

Error "Incorrect use of entity type '<resolvedJavaType.getTypeName()>' (possibly due to missing association mapping annotation)" thrown in hibernate/hibernate-orm.

Source

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

		else {
			length = scale = null;
		}
		return explicitJdbcType.getRecommendedJavaType( length, scale, typeConfiguration );
	}

	private static <T> JdbcType recommendedJdbcType(
			Type resolvedJavaType,
			JdbcTypeIndicators stdIndicators,
			MetadataBuildingContext buildingContext,
			JavaType<T> reflectedJtd) {
		try {
			return reflectedJtd.getRecommendedJdbcType( stdIndicators );
		}
		catch (JdbcTypeRecommendationException jtre) {
			if ( buildingContext.getMetadataCollector()
					.getEntityBindingMap().values().stream()
					.anyMatch( pc -> pc.getMappedClass().equals( resolvedJavaType ) ) ) {
				throw new MappingException( "Incorrect use of entity type '" + resolvedJavaType.getTypeName()
							+ "' (possibly due to missing association mapping annotation)", jtre );
			}
			else {
				throw jtre;
			}
		}
	}

	private static <T> BasicType<T> registeredType(
			JdbcType explicitJdbcType,
			Function<TypeConfiguration, MutabilityPlan<?>> explicitMutabilityPlanAccess,
			JdbcTypeIndicators stdIndicators,
			Selectable selectable,
			JavaType<T> reflectedJtd,
			BootstrapContext bootstrapContext,
			Dialect dialect) {
		final var basicTypeRegistry =
				bootstrapContext.getTypeConfiguration().getBasicTypeRegistry();

View on GitHub (pinned to fad1729dce)

Solutions

  1. Add the missing association annotation (@ManyToOne/@OneToOne/@ElementCollection etc.) on the property referencing the entity type.

Example fix

Add the missing association annotation (@ManyToOne/@OneToOne/@ElementCollection etc.) on the property referencing the entity type.

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