{"record":{"id":"742a45463da90c95","repo":"hibernate/hibernate-orm","slug":"generator-class-classname-implements-identif","errorCode":null,"errorMessage":"Generator class '${className}' implements 'IdentifierGenerator' and may not be used with '@ValueGenerationType'","messagePattern":"Generator class '(.+?)' implements 'IdentifierGenerator' and may not be used with '@ValueGenerationType'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java","lineNumber":362,"sourceCode":"\t\tinterpretTableGenerator( generatorAnnotation, definitionBuilder );\n\t\tif ( BOOT_LOGGER.isTraceEnabled() ) {\n\t\t\tBOOT_LOGGER.addedTableGenerator( definitionBuilder.getName() );\n\t\t}\n\t\treturn definitionBuilder.build();\n\t}\n\n\tprivate static void checkGeneratorClass(Class<? extends Generator> generatorClass) {\n\t\tif ( !BeforeExecutionGenerator.class.isAssignableFrom( generatorClass )\n\t\t\t\t&& !OnExecutionGenerator.class.isAssignableFrom( generatorClass ) ) {\n\t\t\tthrow new MappingException( \"Generator class '\" + generatorClass.getName()\n\t\t\t\t\t+ \"' must implement either 'BeforeExecutionGenerator' or 'OnExecutionGenerator'\" );\n\t\t}\n\t}\n\n\tprivate static void checkGeneratorInterfaces(Class<? extends Generator> generatorClass) {\n\t\t// A regular value generator should not implement legacy IdentifierGenerator\n\t\tif ( IdentifierGenerator.class.isAssignableFrom( generatorClass ) ) {\n\t\t\tthrow new AnnotationException( \"Generator class '\" + generatorClass.getName()\n\t\t\t\t\t+ \"' implements 'IdentifierGenerator' and may not be used with '@ValueGenerationType'\" );\n\t\t}\n\t}\n\n\t/**\n\t * Return a {@link GeneratorCreator} for an attribute annotated\n\t * with a {@linkplain ValueGenerationType generator annotation}.\n\t */\n\tprivate static <A extends Annotation> GeneratorCreator generatorCreator(\n\t\t\tMemberDetails memberDetails,\n\t\t\tValue value,\n\t\t\tA annotation,\n\t\t\tBeanContainer beanContainer) {\n\t\t@SuppressWarnings(\"unchecked\") // totally fine\n\t\tfinal var annotationType = (Class<A>) annotation.annotationType();\n\t\tfinal var generatorAnnotation = annotationType.getAnnotation( ValueGenerationType.class );\n\t\tassert generatorAnnotation != null;\n\t\tfinal var generatorClass = generatorAnnotation.generatedBy();","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java#L344-L380","documentation":"Error \"Generator class '${className}' implements 'IdentifierGenerator' and may not be used with '@ValueGenerationType'\" 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":["Do not use an IdentifierGenerator implementation with @ValueGenerationType; use a value-generation generator instead."],"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"}