{"record":{"id":"47f229ec57a1d801","repo":"hibernate/hibernate-orm","slug":"idbag-mapping-missing-collectionid-annotation","errorCode":null,"errorMessage":"idbag mapping missing '@CollectionId' annotation","messagePattern":"idbag mapping missing '@CollectionId' annotation","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdBagBinder.java","lineNumber":53,"sourceCode":"\n\tpublic IdBagBinder(\n\t\t\tSupplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver,\n\t\t\tMetadataBuildingContext buildingContext) {\n\t\tsuper( customTypeBeanResolver, buildingContext );\n\t}\n\n\t@Override\n\tprotected Collection createCollection(PersistentClass owner) {\n\t\treturn new IdentifierBag( getCustomTypeBeanResolver(), owner, getBuildingContext() );\n\t}\n\n\t@Override\n\tprotected boolean bindStarToManySecondPass(Map<String, PersistentClass> persistentClasses) {\n\t\tfinal boolean result = super.bindStarToManySecondPass( persistentClasses );\n\n\t\tfinal var collectionIdAnn = property.getDirectAnnotationUsage( CollectionId.class );\n\t\tif ( collectionIdAnn == null ) {\n\t\t\tthrow new MappingException( \"idbag mapping missing '@CollectionId' annotation\" );\n\t\t}\n\n\t\tfinal var propertyData = new WrappedInferredData(\n\t\t\t\tnew PropertyInferredData(\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tdeclaringClass,\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t//default access should not be useful\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tbuildingContext\n\t\t\t\t),\n\t\t\t\t\"id\"\n\t\t);\n\n\t\tfinal var idColumns = AnnotatedColumn.buildColumnsFromAnnotations(\n\t\t\t\tnew Column[]{collectionIdAnn.column()},\n//\t\t\t\tnull,\n\t\t\t\tnull,","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdBagBinder.java#L35-L71","documentation":"Error \"idbag mapping missing '@CollectionId' annotation\" 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":["Add @CollectionId to the idbag collection mapping, or change the mapping type."],"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"}