hibernate/hibernate-orm · error · AnnotationException

Entity '<entityName>' has '@Id' annotated properties <proper

Error message

Entity '<entityName>' has '@Id' annotated properties <properties> which do not match properties of the specified '@IdClass'

What it means

Error "Entity '<entityName>' has '@Id' annotated properties <properties> which do not match properties of the specified '@IdClass'" thrown in hibernate/hibernate-orm.

Source

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

							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
					: Nullability.NO_CONSTRAINT;
		}
	}

	private void addGenericProperties(

View on GitHub (pinned to fad1729dce)

Solutions

  1. Align the entity @Id properties with the properties of the specified @IdClass.

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