{"record":{"id":"34bec19b61ced54f","repo":"hibernate/hibernate-orm","slug":"only-basic-and-to-one-attributes-are-supported-in","errorCode":null,"errorMessage":"Only basic and to-one attributes are supported in composite fks","messagePattern":"Only basic and to-one attributes are supported in composite fks","errorType":"exception","errorClass":"UnsupportedMappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java","lineNumber":252,"sourceCode":"\n\t\t\t\tattributeMapping = toOne;\n\t\t\t\tcurrentIndex += attributeMapping.getJdbcTypeCount();\n\t\t\t}\n\t\t\telse if ( attributeMapping instanceof EmbeddableValuedModelPart embeddableValuedModelPart ) {\n\t\t\t\tfinal var subMappings = new SelectableMapping[attributeMapping.getJdbcTypeCount()];\n\t\t\t\tfor ( int i = 0; i < subMappings.length; i++ ) {\n\t\t\t\t\tsubMappings[i] = selectableMappings.getSelectable( currentIndex++ );\n\t\t\t\t}\n\t\t\t\tattributeMapping = MappingModelCreationHelper.createInverseModelPart(\n\t\t\t\t\t\tembeddableValuedModelPart,\n\t\t\t\t\t\tdeclaringType,\n\t\t\t\t\t\tdeclaringTableGroupProducer,\n\t\t\t\t\t\tnew SelectableMappingsImpl( subMappings ),\n\t\t\t\t\t\tcreationProcess\n\t\t\t\t);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new UnsupportedMappingException(\n\t\t\t\t\t\t\"Only basic and to-one attributes are supported in composite fks\" );\n\t\t\t}\n\t\t\tmappings.add( attributeMapping );\n\t\t}\n\t\tattributeMappings = mappings.build();\n\t\tbuildGetterSetterCache();\n\t\treturn true;\n\t}\n\n\tprotected boolean finishInitialization(\n\t\t\tNavigableRole navigableRole,\n\t\t\tComponent bootDescriptor,\n\t\t\tCompositeType compositeType,\n\t\t\tString rootTableExpression,\n\t\t\tString[] rootTableKeyColumnNames,\n\t\t\tEmbeddableMappingType declarer,\n\t\t\tEmbeddableRepresentationStrategy representationStrategy,\n\t\t\tAttributeTypeValidator attributeTypeValidator,","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java#L234-L270","documentation":"Error \"Only basic and to-one attributes are supported in composite fks\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when a composite foreign key includes an attribute that is neither basic nor to-one (e.g. a plural or any attribute inside an embeddable key).","commonSituations":"See trigger scenarios.","solutions":["Map the foreign key of the embedded id/reference using only basic attributes and to-one associations; move collections or other unsupported attributes out of the key."],"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"}