hibernate/hibernate-orm · error · MappingException
Annotation '${annotationType}' is annotated 'IdGeneratorType
Error message
Annotation '${annotationType}' is annotated 'IdGeneratorType' but the given 'Generator' generates on updates (it must generate only on inserts) What it means
Error "Annotation '${annotationType}' is annotated 'IdGeneratorType' but the given 'Generator' generates on updates (it must generate only on inserts)" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java:680
.requireService( ConfigurationService.class )
);
configurable.configure( creationContext, parameters );
}
if ( generator instanceof ExportableProducer exportableProducer ) {
exportableProducer.registerExportables( creationContext.getDatabase() );
}
if ( generator instanceof Configurable configurable ) {
configurable.initialize( creationContext.getSqlStringGenerationContext() );
}
}
private static void checkIdGeneratorTiming(Class<? extends Annotation> annotationType, Generator generator) {
if ( !generator.generatesOnInsert() ) {
throw new MappingException( "Annotation '" + annotationType
+ "' is annotated 'IdGeneratorType' but the given 'Generator' does not generate on inserts" );
}
if ( generator.generatesOnUpdate() ) {
throw new MappingException( "Annotation '" + annotationType
+ "' is annotated 'IdGeneratorType' but the given 'Generator' generates on updates (it must generate only on inserts)" );
}
}
/**
* Create a generator, based on a {@link GeneratedValue} annotation.
*/
private static void createIdGenerator(
MemberDetails idMember,
SimpleValue idValue,
PersistentClass persistentClass,
MetadataBuildingContext context) {
// NOTE: generatedValue is never null here
final var generatedValue = castNonNull( idMember.getDirectAnnotationUsage( GeneratedValue.class ) );
final var metadataCollector = context.getMetadataCollector();
if ( isGlobalGeneratorNameGlobal( context ) ) {
// process and register any generators defined on the member.
// according to JPA these are also global.View on GitHub (pinned to fad1729dce)
Solutions
- Use a generator that generates only on inserts; remove update-time generation.
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/65ef18809772bfc3.
Report an issue: GitHub.