hibernate/hibernate-orm · error · AnnotationException

Property '<propertyName>' of '<path>' is annotated '@Generat

Error message

Property '<propertyName>' of '<path>' is annotated '@GeneratedValue' but is not part of an identifier

What it means

Error "Property '<propertyName>' of '<path>' is annotated '@GeneratedValue' but is not part of an identifier" thrown in hibernate/hibernate-orm.

Source

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

			PropertyData propertyAnnotatedElement, PropertyHolder subholder,
			Component embeddable,
			MetadataBuildingContext context) {
		final var memberDetails = propertyAnnotatedElement.getAttributeMember();
		if ( isIdClass || subholder.isOrWithinEmbeddedId() ) {
			final var property = findProperty( embeddable, propertyAnnotatedElement.getPropertyName() );
			if ( property != null ) {
				// Identifier properties are always simple values
				final var value = (SimpleValue) property.getValue();
				createIdGeneratorsFromGeneratorAnnotations(
						subholder,
						propertyAnnotatedElement,
						value,
						context
				);
			}
		}
		else if ( memberDetails.hasDirectAnnotationUsage( GeneratedValue.class ) ) {
			throw new AnnotationException(
					"Property '" + memberDetails.getName() + "' of '"
							+ getPath( propertyHolder, inferredData )
							+ "' is annotated '@GeneratedValue' but is not part of an identifier" );
		}
	}

	private static Property findProperty(Component embeddable, String name) {
		for ( var property : embeddable.getProperties() ) {
			if ( property.getName().equals( name ) ) {
				return property;
			}
		}
		return null;
	}

	private static CompositeUserType<?> compositeUserType(
			Class<? extends CompositeUserType<?>> compositeUserTypeClass,
			MetadataBuildingContext context) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove @GeneratedValue from the non-identifier property of the embeddable.
  2. Or restructure so the generated property is the entity identifier.

When it happens

Trigger: An identifier/value generator declaration is inconsistent with the referenced generator or the annotated element.

Common situations: @GeneratedValue pointing at a generator of the wrong kind (SEQUENCE vs TABLE), a missing named generator, too many generator annotations, or an unsupported generation strategy for @CollectionId.


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