hibernate/hibernate-orm · error · MappingException
IDENTITY generation not supported for @CollectionId
Error message
IDENTITY generation not supported for @CollectionId
What it means
Error "IDENTITY generation not supported for @CollectionId" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdBagBinder.java:126
generatorName( generator ),
getBuildingContext(),
localGenerators
);
}
return result;
}
private static String generatorName(String generator) {
return switch ( generator ) {
case "sequence", "increment" -> "";
default -> generator;
};
}
private static void checkLegalCollectionIdStrategy(String namedGenerator) {
switch ( namedGenerator ) {
case "identity":
throw new MappingException("IDENTITY generation not supported for @CollectionId");
case "assigned":
throw new MappingException("Assigned generation not supported for @CollectionId");
case "native":
throw new MappingException("Native generation not supported for @CollectionId");
}
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Use a generation strategy other than IDENTITY for @CollectionId.
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/5bafdcdb6f75c7dd.
Report an issue: GitHub.