hibernate/hibernate-orm · error · AnnotationException
Property '<path>' is annotated '@GeneratedValue' but is not
Error message
Property '<path>' is annotated '@GeneratedValue' but is not part of an identifier
What it means
Error "Property '<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/EntityBinder.java:1132
InheritanceState inheritanceState,
MetadataBuildingContext context,
PropertyHolder propertyHolder,
Set<String> idPropertiesIfIdClass,
ElementsToProcess elementsToProcess,
Map<ClassDetails, InheritanceState> inheritanceStates) {
final Set<String> missingIdProperties = new HashSet<>( idPropertiesIfIdClass );
final Set<String> missingEntityProperties = new HashSet<>();
for ( var propertyAnnotatedElement : elementsToProcess.getElements() ) {
final String propertyName = propertyAnnotatedElement.getPropertyName();
if ( !idPropertiesIfIdClass.contains( propertyName ) ) {
final var memberDetails = propertyAnnotatedElement.getAttributeMember();
final boolean hasIdAnnotation = hasIdAnnotation( memberDetails );
if ( !idPropertiesIfIdClass.isEmpty() && !isIgnoreIdAnnotations() && hasIdAnnotation ) {
missingEntityProperties.add( propertyName );
}
else {
if ( !hasIdAnnotation && memberDetails.hasAnnotationUsage( GeneratedValue.class, modelsContext() ) ) {
throw new AnnotationException( "Property '" + getPath( propertyHolder, propertyAnnotatedElement )
+ "' is annotated '@GeneratedValue' but is not part of an identifier" );
}
processElementAnnotations(
propertyHolder,
getNullability( inheritanceState, memberDetails ),
propertyAnnotatedElement,
this,
false,
false,
false,
context,
inheritanceStates
);
}
}
else {
missingIdProperties.remove( propertyName );
}View on GitHub (pinned to fad1729dce)
Solutions
- Remove @GeneratedValue from the non-identifier property, or make the property part of the 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/aab93a33c12f0910.
Report an issue: GitHub.