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