{"record":{"id":"f2bcd9d88db5e0b9","repo":"hibernate/hibernate-orm","slug":"idbag-mapping-missing-collectionid","errorCode":null,"errorMessage":"idbag mapping missing @CollectionId","messagePattern":"idbag mapping missing @CollectionId","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java","lineNumber":402,"sourceCode":"\t\t\t\tbreak;\n\t\t\tcase LIST_INDEX:\n\t\t\t\tprepareListIndex( value );\n\t\t\t\tbreak;\n\t\t\tcase MAP_KEY:\n\t\t\t\tprepareMapKey( value, typeDetails );\n\t\t\t\tbreak;\n\t\t\tcase COLLECTION_ELEMENT:\n\t\t\t\tprepareCollectionElement( value, typeDetails );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new IllegalArgumentException( \"Unexpected binder type : \" + kind );\n\t\t}\n\t}\n\n\tprivate void prepareCollectionId(MemberDetails attribute) {\n\t\tfinal var collectionId = attribute.getDirectAnnotationUsage( CollectionId.class );\n\t\tif ( collectionId == null ) {\n\t\t\tthrow new MappingException( \"idbag mapping missing @CollectionId\" );\n\t\t}\n\n\t\tfinal boolean useDeferredBeanContainerAccess = useDeferredBeanContainerAccess();\n\t\tfinal var beanRegistry = getManagedBeanRegistry();\n\n\t\timplicitJavaTypeAccess = typeConfiguration -> null;\n\n\t\tfinal var modelContext = getSourceModelContext();\n\n\t\texplicitJavaTypeAccess = typeConfiguration -> {\n\t\t\tfinal var idJavaClass = attribute.locateAnnotationUsage( CollectionIdJavaClass.class, modelContext );\n\t\t\tif ( idJavaClass != null ) {\n\t\t\t\treturn (BasicJavaType<?>)\n\t\t\t\t\t\tbuildingContext.getBootstrapContext().getTypeConfiguration()\n\t\t\t\t\t\t\t\t.getJavaTypeRegistry().resolveDescriptor( idJavaClass.idType() );\n\t\t\t}\n\t\t\tfinal var idJavaType = attribute.locateAnnotationUsage( CollectionIdJavaType.class, modelContext );\n\t\t\tif ( idJavaType != null ) {","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java#L384-L420","documentation":"Error \"idbag mapping missing @CollectionId\" 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 a @CollectionId annotation to the idbag collection mapping.","Or change the collection mapping from idbag to a bag or list mapping that does not require @CollectionId."],"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"}