{"record":{"id":"d99a2b9124ccaccd","repo":"hibernate/hibernate-orm","slug":"support-for-attribute-mapping-type-not-yet-impleme","errorCode":null,"errorMessage":"Support for attribute mapping type not yet implemented: ","messagePattern":"Support for attribute mapping type not yet implemented: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/XmlHelper.java","lineNumber":810,"sourceCode":"\t\t\t\t\t\tsb.append( \"/>\" );\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tsb.append( '>' );\n\t\t\t\t}\n\t\t\t\ttoString(\n\t\t\t\t\t\tmappingType,\n\t\t\t\t\t\tattributeValue == null ? null : mappingType.getValues( attributeValue ),\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\tsb\n\t\t\t\t);\n\t\t\t\tif ( tagName != null ) {\n\t\t\t\t\tsb.append( \"</\" );\n\t\t\t\t\tsb.append( tagName );\n\t\t\t\t\tsb.append( '>' );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new UnsupportedOperationException( \"Support for attribute mapping type not yet implemented: \" + attributeMapping.getClass().getName() );\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void convertedBasicValueToString(\n\t\t\tXMLAppender appender,\n\t\t\tObject value,\n\t\t\tWrapperOptions options,\n\t\t\tJavaType<Object> jdbcJavaType,\n\t\t\tJdbcType jdbcType) {\n\t\tswitch ( jdbcType.getDefaultSqlTypeCode() ) {\n\t\t\tcase SqlTypes.TINYINT:\n\t\t\tcase SqlTypes.SMALLINT:\n\t\t\tcase SqlTypes.INTEGER:\n\t\t\t\tif ( value instanceof Boolean booleanValue ) {\n\t\t\t\t\t// BooleanJavaType has this as an implicit conversion\n\t\t\t\t\tappender.append( booleanValue ? '1' : '0' );\n\t\t\t\t\tbreak;","sourceCodeStart":792,"sourceCodeEnd":828,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/XmlHelper.java#L792-L828","documentation":"XmlHelper.toString serializes XML aggregates but implements only two attribute mapping kinds: basic selectables and nested embeddables (EmbeddedAttributeMapping). When writing, any other attribute kind inside the embeddable - a to-one association, a discriminated (@Any) association, or a plural/collection attribute - throws UnsupportedOperationException with the mapping class name.","triggerScenarios":"Inserting or updating an entity whose XML-mapped embeddable contains a @ManyToOne/@OneToOne, @Any, or collection attribute. The failure occurs at write time when the aggregate is serialized to the XML column.","commonSituations":"Growing an existing XML aggregate embeddable with an association during development; porting struct mappings (which allow to-one FK parts) to XML columns; upgrades that surface previously latent mappings.","solutions":["Restrict XML-mapped embeddables to basic fields and nested embeddables only.","Replace the association with plain FK columns stored as basic attributes inside the aggregate.","Move associations and collections out of the aggregate onto the owning entity.","Check the Hibernate version's aggregate support matrix before adding such attributes."],"exampleFix":"// before\n@Embeddable\npublic class Contact {\n    String email;\n    @OneToMany(mappedBy = \"contact\")   // collection inside XML aggregate\n    List<Phone> phones;                // -> Support for attribute mapping type not yet implemented\n}\n// after: keep only scalars in the aggregate\n@Embeddable\npublic class Contact {\n    String email;\n    String primaryPhone;\n}","handlingStrategy":"validation","validationCode":"static void assertXmlAggregateWritable(Class<?> embeddable) {\n    for (Field f : embeddable.getDeclaredFields()) {\n        if (f.isAnnotationPresent(ManyToOne.class) || f.isAnnotationPresent(OneToOne.class)\n                || f.isAnnotationPresent(OneToMany.class) || f.isAnnotationPresent(ManyToMany.class)\n                || f.isAnnotationPresent(Any.class)) {\n            throw new IllegalStateException(\n                \"XML aggregate cannot serialize attribute: \" + f);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    session.persist(person);   // or merge/update\n} catch (UnsupportedOperationException ex) {\n    if (ex.getMessage() != null && ex.getMessage().startsWith(\"Support for attribute mapping type\")) {\n        throw new DataMappingException(\"XML aggregate contains unsupported attribute type\", ex);\n    }\n    throw ex;\n}","preventionTips":["Design XML aggregate embeddables with scalars and nested embeddables only.","Run the write path in an integration test, not just boot-time schema validation.","Model associations outside the aggregate on the owning entity."],"tags":["hibernate","xml","xml-aggregate","unsupported-mapping","serialization"],"backgroundTag":"unsupported-mapping-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}