{"record":{"id":"65ef18809772bfc3","repo":"hibernate/hibernate-orm","slug":"annotation-annotationtype-is-annotated-idgen-65ef18","errorCode":null,"errorMessage":"Annotation '${annotationType}' is annotated 'IdGeneratorType' but the given 'Generator' generates on updates (it must generate only on inserts)","messagePattern":"Annotation '(.+?)' is annotated 'IdGeneratorType' but the given 'Generator' generates on updates \\(it must generate only on inserts\\)","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java","lineNumber":680,"sourceCode":"\t\t\t\t\t\t\t.requireService( ConfigurationService.class )\n\t\t\t);\n\t\t\tconfigurable.configure( creationContext, parameters );\n\t\t}\n\t\tif ( generator instanceof ExportableProducer exportableProducer ) {\n\t\t\texportableProducer.registerExportables( creationContext.getDatabase() );\n\t\t}\n\t\tif ( generator instanceof Configurable configurable ) {\n\t\t\tconfigurable.initialize( creationContext.getSqlStringGenerationContext() );\n\t\t}\n\t}\n\n\tprivate static void checkIdGeneratorTiming(Class<? extends Annotation> annotationType, Generator generator) {\n\t\tif ( !generator.generatesOnInsert() ) {\n\t\t\tthrow new MappingException( \"Annotation '\" + annotationType\n\t\t\t\t\t+ \"' is annotated 'IdGeneratorType' but the given 'Generator' does not generate on inserts\" );\n\t\t}\n\t\tif ( generator.generatesOnUpdate() ) {\n\t\t\tthrow new MappingException( \"Annotation '\" + annotationType\n\t\t\t\t\t+ \"' is annotated 'IdGeneratorType' but the given 'Generator' generates on updates (it must generate only on inserts)\" );\n\t\t}\n\t}\n\n\t/**\n\t * Create a generator, based on a {@link GeneratedValue} annotation.\n\t */\n\tprivate static void createIdGenerator(\n\t\t\tMemberDetails idMember,\n\t\t\tSimpleValue idValue,\n\t\t\tPersistentClass persistentClass,\n\t\t\tMetadataBuildingContext context) {\n\t\t// NOTE: generatedValue is never null here\n\t\tfinal var generatedValue = castNonNull( idMember.getDirectAnnotationUsage( GeneratedValue.class ) );\n\t\tfinal var metadataCollector = context.getMetadataCollector();\n\t\tif ( isGlobalGeneratorNameGlobal( context ) ) {\n\t\t\t// process and register any generators defined on the member.\n\t\t\t// according to JPA these are also global.","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java#L662-L698","documentation":"Error \"Annotation '${annotationType}' is annotated 'IdGeneratorType' but the given 'Generator' generates on updates (it must generate only on inserts)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An identifier/value generator declaration is inconsistent with the referenced generator or the annotated element.","commonSituations":"@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.","solutions":["Use a generator that generates only on inserts; remove update-time generation."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}