{"record":{"id":"d3fae5d5a83c8531","repo":"hibernate/hibernate-orm","slug":"annotation-annotationtype-is-annotated-idgen","errorCode":null,"errorMessage":"Annotation '${annotationType}' is annotated 'IdGeneratorType' but the given 'Generator' does not generate on inserts","messagePattern":"Annotation '(.+?)' is annotated 'IdGeneratorType' but the given 'Generator' does not generate on inserts","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java","lineNumber":676,"sourceCode":"\t\t\t\t\tcreationContext.getDatabase().getDialect(),\n\t\t\t\t\tcreationContext.getRootClass(),\n\t\t\t\t\tconfiguration,\n\t\t\t\t\tcreationContext.getServiceRegistry()\n\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 ) );","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java#L658-L694","documentation":"Error \"Annotation '${annotationType}' is annotated 'IdGeneratorType' but the given 'Generator' does not generate 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 on inserts for the @IdGeneratorType annotation."],"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"}