hibernate/hibernate-orm · error · MappingException
Annotation '${annotationType}' is annotated 'IdGeneratorType
Error message
Annotation '${annotationType}' is annotated 'IdGeneratorType' but the given 'Generator' does not generate on inserts What it means
Error "Annotation '${annotationType}' is annotated 'IdGeneratorType' but the given 'Generator' does not generate on inserts" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java:676
creationContext.getDatabase().getDialect(),
creationContext.getRootClass(),
configuration,
creationContext.getServiceRegistry()
.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 ) );View on GitHub (pinned to fad1729dce)
Solutions
- Use a generator that generates on inserts for the @IdGeneratorType annotation.
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/d3fae5d5a83c8531.
Report an issue: GitHub.