hibernate/hibernate-orm · error · AnnotationException

Unknown entity name '<referencedEntityName>'

Error message

Unknown entity name '<referencedEntityName>'

What it means

Error "Unknown entity name '<referencedEntityName>'" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java:1248

						index,
						referencedProperty
				);
			}
			else {
				return createSimpleProperty(
						referencedPersistentClass,
						isExplicitReference,
						columnByReferencedName,
						index,
						referencedProperty
				);
			}
		}

		private Component getReferencedComponent(PersistentClass referencedPersistentClass) {
			if ( referencedPersistentClass == null ) {
				// TODO: much better error message if this is something that can really happen!
				throw new AnnotationException( "Unknown entity name '" + referencedEntityName + "'");
			}
			if ( referencedPersistentClass.getIdentifier() instanceof Component id ) {
				return id;
			}
			else {
				// The entity with the @MapsId annotation has a composite
				// id type, but the referenced entity has a basic-typed id.
				// Therefore, the @MapsId annotation should have specified
				// a property of the composite id that has the foreign key
				throw new AnnotationException(
						"Missing 'value' in '@MapsId' annotation of association '" + propertyName
						+ "' of entity '" + embeddable.getOwner().getEntityName()
						+ "' with composite identifier type"
						+ " ('@MapsId' must specify a property of the '@EmbeddedId' class which has the foreign key of '"
						+ referencedEntityName + "')"
				);
			}
		}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Correct the referenced entity name to a registered entity of the persistence unit.

When it happens

Trigger: An association or reference targets a type that Hibernate has not mapped as an entity.

Common situations: Missing @Entity on the target class, the class not being scanned into the persistence unit, or a typo in the entity name.


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