hibernate/hibernate-orm · error · MappingException
@GeneratedValue for %s (%s) specified SEQUENCE generation, b
Error message
@GeneratedValue for %s (%s) specified SEQUENCE generation, but referred to a @TableGenerator
What it means
Error "@GeneratedValue for %s (%s) specified SEQUENCE generation, but referred to a @TableGenerator" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdGeneratorResolverSecondPass.java:110
if ( globalMatch != null ) {
handleSequenceGenerator( generator, globalMatch.configuration(), idValue, idMember, buildingContext );
}
else {
validateSequenceGeneration();
handleSequenceGenerator( generator, null, idValue, idMember, buildingContext );
}
}
}
private void validateSequenceGeneration() {
// basically, make sure there is neither a TableGenerator nor GenericGenerator with this name
final var globalRegistrations = buildingContext.getMetadataCollector().getGlobalRegistrations();
final String generator = generatedValue.generator();
final var globalTableMatch = globalRegistrations.getTableGeneratorRegistrations().get( generator );
if ( globalTableMatch != null ) {
throw new MappingException(
String.format(
Locale.ROOT,
"@GeneratedValue for %s (%s) specified SEQUENCE generation, but referred to a @TableGenerator",
entityMapping.getEntityName(),
generator
)
);
}
final var globalGenericMatch = globalRegistrations.getGenericGeneratorRegistrations().get( generator );
if ( globalGenericMatch != null ) {
throw new MappingException(
String.format(
Locale.ROOT,
"@GeneratedValue for %s (%s) specified SEQUENCE generation, but referred to a @GenericGenerator",
entityMapping.getEntityName(),
generator
)View on GitHub (pinned to fad1729dce)
Solutions
- Reference a @SequenceGenerator for SEQUENCE generation, or change the strategy to TABLE.
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/b3f2e997fd7d5160.
Report an issue: GitHub.