hibernate/hibernate-orm · error · AnnotationException

Entity ' ' has '@Id' annotated properties which do not…

Error message

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

What it means

IdClass-conformance guard (inverse direction): the entity has @Id-annotated properties left over that are not members of the declared @IdClass. Every entity id property must also appear in the id class.

Solutions

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

Strategy: validation

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.

Appendix: 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)