hibernate/hibernate-orm · error · AnnotationException

Class ' ' is the '@IdClass' for the entity ' ' but has no…

Error message

Class '<componentClassName>' is the '@IdClass' for the entity '<entityName>' but has no persistent properties

What it means

Post-binding guard in bindIdClass: after filling the id-class component, it contributed zero persistent properties. An @IdClass with no mapped fields cannot serve as a composite identifier.

Solutions

  1. Add persistent properties to the @IdClass matching the entity identifier properties.
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/34b4705184bb94a6. Report an issue: GitHub.

Appendix: source

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

				false,
				this,
				true,
				false,
				false,
				null,
				null,
				null,
				buildingContext,
				inheritanceStates,
				true
		);
		id.setKey( true );
		if ( rootClass.getIdentifier() != null ) {
			throw new AssertionFailure( "Entity '" + persistentClass.getEntityName()
					+ "' has an '@IdClass' and may not have an identifier property" );
		}
		if ( id.getPropertySpan() == 0 ) {
			throw new AnnotationException( "Class '" + id.getComponentClassName()
					+ " is the '@IdClass' for the entity '" + persistentClass.getEntityName()
					+ "' but has no persistent properties" );
		}

		rootClass.setIdentifier( id );
		rootClass.setEmbeddedIdentifier( inferredData.getPropertyType() == null );
		propertyHolder.setInIdClass( null );
		return id;
	}

	private void handleSecondaryTables() {
		annotatedClass.forEachRepeatedAnnotationUsages( JpaAnnotations.SECONDARY_TABLE, modelsContext(),
				usage -> addSecondaryTable( usage, null, false ) );
	}

	private void handleClassTable(InheritanceState inheritanceState, PersistentClass superEntity) {
		final String schema;
		final String table;

View on GitHub (pinned to fad1729dce)