{"record":{"id":"bb116cb2e342f9e5","repo":"hibernate/hibernate-orm","slug":"identifier-attribute-s-has-too-many-generator-a","errorCode":null,"errorMessage":"Identifier attribute '%s' has too many generator annotations: %s","messagePattern":"Identifier attribute '(.+?)' has too many generator annotations: (.+?)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java","lineNumber":845,"sourceCode":"\tstatic void createIdGeneratorsFromGeneratorAnnotations(\n\t\t\tPropertyHolder propertyHolder,\n\t\t\tPropertyData inferredData,\n\t\t\tSimpleValue idValue,\n\t\t\tMetadataBuildingContext buildingContext) {\n\t\tfinal var modelsContext = buildingContext.getBootstrapContext().getModelsContext();\n\t\tfinal var idMemberDetails = inferredData.getAttributeMember();\n\t\tfinal var idGeneratorAnnotations = idMemberDetails.getMetaAnnotated( IdGeneratorType.class, modelsContext );\n\t\tfinal var generatorAnnotations = idMemberDetails.getMetaAnnotated( ValueGenerationType.class, modelsContext );\n\t\t// Since these collections may contain proxies created by common-annotations module, we cannot reliably use\n\t\t// simple remove/removeAll collection methods as those proxies do not implement hashcode/equals and even a\n\t\t// simple 'a.equals(a)' will return 'false'. Instead, we will check the annotation types. Since generator\n\t\t// annotations should not be \"repeatable\", we should have only at most one annotation for a generator.\n\t\tfor ( var id : idGeneratorAnnotations ) {\n\t\t\tgeneratorAnnotations.removeIf( gen -> gen.annotationType().equals( id.annotationType() ) );\n\t\t}\n\n\t\tif ( idGeneratorAnnotations.size() + generatorAnnotations.size() > 1 ) {\n\t\t\tthrow new AnnotationException( String.format(\n\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\"Identifier attribute '%s' has too many generator annotations: %s\",\n\t\t\t\t\tgetPath( propertyHolder, inferredData ),\n\t\t\t\t\tcombineUntyped( idGeneratorAnnotations, generatorAnnotations )\n\t\t\t) );\n\t\t}\n\t\tif ( !idGeneratorAnnotations.isEmpty() ) {\n\t\t\tidValue.setCustomIdGeneratorCreator( identifierGeneratorCreator(\n\t\t\t\t\tidMemberDetails,\n\t\t\t\t\tidGeneratorAnnotations.get(0),\n\t\t\t\t\tidValue,\n\t\t\t\t\tbeanContainer( buildingContext )\n\t\t\t) );\n\t\t}\n\t\telse if ( !generatorAnnotations.isEmpty() ) {\n//\t\t\tidValue.setCustomGeneratorCreator( generatorCreator( idMemberDetails, generatorAnnotation ) );\n\t\t\tthrow new AnnotationException( String.format(\n\t\t\t\t\tLocale.ROOT,","sourceCodeStart":827,"sourceCodeEnd":863,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/GeneratorBinder.java#L827-L863","documentation":"Error \"Identifier attribute '%s' has too many generator annotations: %s\" 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":["Keep only one generator annotation on the identifier attribute."],"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"}