hibernate/hibernate-orm · error · AnnotationException

Entity '<entityName>' has an '@IdClass' with properties <pro

Error message

Entity '<entityName>' has an '@IdClass' with properties <properties> which do not match properties of the entity class

What it means

Error "Entity '<entityName>' has an '@IdClass' with properties <properties> which do not match properties of the entity class" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java:1155

							getNullability( inheritanceState, memberDetails ),
							propertyAnnotatedElement,
							this,
							false,
							false,
							false,
							context,
							inheritanceStates
					);
				}
			}
			else {
				missingIdProperties.remove( propertyName );
			}
		}
		addGenericProperties( persistentClass, inheritanceState, inheritanceStates );

		if ( !missingIdProperties.isEmpty() ) {
			throw new AnnotationException( "Entity '" + persistentClass.getEntityName()
					+ "' has an '@IdClass' with properties " + getMissingPropertiesString( missingIdProperties )
					+ " which do not match properties of the entity class" );
		}
		else if ( !missingEntityProperties.isEmpty() ) {
			throw new AnnotationException( "Entity '" + persistentClass.getEntityName()
					+ "' has '@Id' annotated properties " + getMissingPropertiesString( missingEntityProperties )
					+ " which do not match properties of the specified '@IdClass'" );
		}
	}

	private static Nullability getNullability(InheritanceState inheritanceState, MemberDetails memberDetails) {
		if ( isVersion( memberDetails ) ) {
			return Nullability.FORCED_NOT_NULL;
		}
		else {
			return inheritanceState.getType() == SINGLE_TABLE
				&& inheritanceState.hasParents()
					? Nullability.FORCED_NULL

View on GitHub (pinned to fad1729dce)

Solutions

  1. Make the @IdClass properties match the entity identifier properties in name and type.

When it happens

Trigger: A composite identifier mapping (@IdClass/@EmbeddedId/@MapsId) does not match the entity's persistent properties.

Common situations: Composite primary keys where the id class properties, their types, or @MapsId values drift out of sync with the entity, or an embeddable with inheritance is reused as an id.


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