{"record":{"id":"3a1ec80ff6ae4a2a","repo":"hibernate/hibernate-orm","slug":"conversion-of-id-attributes-not-supported","errorCode":null,"errorMessage":"Conversion of id attributes not supported","messagePattern":"Conversion of id attributes not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/HbmXmlTransformer.java","lineNumber":4123,"sourceCode":"\tprivate JaxbIdImpl transformNonAggregatedKeyProperty(\n\t\t\tJaxbHbmCompositeKeyBasicAttributeType hbmIdProperty,\n\t\t\tPropertyInfo idPropertyInfo) {\n\t\tfinal var jaxbBasic = new JaxbIdImpl();\n\t\tjaxbBasic.setName( hbmIdProperty.getName() );\n\t\ttransferAccess(\n\t\t\t\thbmIdProperty.getAccess(),\n\t\t\t\tjaxbBasic::setAccess,\n\t\t\t\tjaxbBasic::setAttributeAccessor\n\t\t);\n\n\t\tapplyBasicTypeMapping(\n\t\t\t\t(BasicValue) idPropertyInfo.bootModelProperty().getValue(),\n\t\t\t\tjaxbBasic,\n\t\t\t\thbmIdProperty.getTypeAttribute(),\n\t\t\t\thbmIdProperty.getType(),\n\t\t\t\tnull,\n\t\t\t\tbasicValueConverter -> {\n\t\t\t\t\tthrow new UnsupportedOperationException( \"Conversion of id attributes not supported\" );\n\t\t\t\t}\n\t\t);\n\n\t\ttransferColumnsAndFormulas(\n\t\t\t\tidPropertyInfo,\n\t\t\t\tnew ColumnAndFormulaSource() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic String getColumnAttribute() {\n\t\t\t\t\t\treturn hbmIdProperty.getColumnAttribute();\n\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic String getFormulaAttribute() {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic List<Serializable> getColumnOrFormula() {","sourceCodeStart":4105,"sourceCodeEnd":4141,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/HbmXmlTransformer.java#L4105-L4141","documentation":"During transformation of an hbm.xml <id> property, applyBasicTypeMapping is given a callback that rejects converters. If the resolved BasicValue for the identifier carries a value converter (a converter-backed basic type), the callback throws UnsupportedOperationException - id attributes that require relational<->domain conversion are explicitly unsupported by the transformer.","triggerScenarios":"An <id> whose 'type' resolves to a converted basic type - e.g. legacy converter-backed types such as yes/no character encoding, numeric-encoded enums, or any custom AttributeConverter-backed type registered for the id column.","commonSituations":"Legacy schemas storing boolean ids as CHAR(1) 'Y'/'N' with type=\"yes_no\"; ids stored encoded (e.g. 'M'/'F' style codes) via custom types; migration of such mappings to mapping.xml.","solutions":["Change the <id> to a plain, converter-free basic type (numeric, string, uuid) that matches the column as stored","Or keep that mapping in native hbm.xml and transform only the rest","Or hand-write the mapping.xml id using a plain type and move the conversion into the application layer","If the encoded storage is a hard requirement, keep the whole mapping on hbm.xml/annotations instead of transformation"],"exampleFix":"<!-- before -->\n<id name=\"activeFlag\" type=\"yes_no\" column=\"active_flag\"/>\n\n<!-- after: use the raw representation; convert in code if needed -->\n<id name=\"activeFlag\" type=\"string\" column=\"active_flag\" length=\"1\"/>","handlingStrategy":"try-catch","validationCode":"// flag converter-backed types on <id> before transform (yes_no, converted customs, ...)\nvar ids = doc.getElementsByTagName(\"id\");\nSet<String> converterBacked = Set.of(\"yes_no\", \"true_false\", \"numeric_boolean\", \"char_boolean\");\nfor (int i = 0; i < ids.getLength(); i++) {\n    String t = ((org.w3c.dom.Element) ids.item(i)).getAttribute(\"type\");\n    if (converterBacked.contains(t)) {\n        throw new IllegalStateException(\"<id> uses converter-backed type '\" + t + \"' - not transformable\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    transformer.transform(hbmSource);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"Conversion of id attributes\")) {\n        // change the id to a plain basic type or keep this mapping native hbm.xml\n    }\n    throw e;\n}","preventionTips":["Avoid converter-backed types on identifiers in hbm destined for transformation","Audit ids stored as encoded characters (Y/N, T/F) before migration","Move value conversion for ids into application code or DB defaults"],"tags":["hibernate","hbm-xml","identifier","attribute-converter","mapping-transformation"],"backgroundTag":"unsupported-orm-mapping-feature","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}