hibernate/hibernate-orm · error · UnsupportedOperationException
Support for attribute mapping type not yet implemented:
Error message
Support for attribute mapping type not yet implemented:
What it means
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.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/XmlHelper.java:810
sb.append( "/>" );
continue;
}
sb.append( '>' );
}
toString(
mappingType,
attributeValue == null ? null : mappingType.getValues( attributeValue ),
options,
sb
);
if ( tagName != null ) {
sb.append( "</" );
sb.append( tagName );
sb.append( '>' );
}
}
else {
throw new UnsupportedOperationException( "Support for attribute mapping type not yet implemented: " + attributeMapping.getClass().getName() );
}
}
}
private static void convertedBasicValueToString(
XMLAppender appender,
Object value,
WrapperOptions options,
JavaType<Object> jdbcJavaType,
JdbcType jdbcType) {
switch ( jdbcType.getDefaultSqlTypeCode() ) {
case SqlTypes.TINYINT:
case SqlTypes.SMALLINT:
case SqlTypes.INTEGER:
if ( value instanceof Boolean booleanValue ) {
// BooleanJavaType has this as an implicit conversion
appender.append( booleanValue ? '1' : '0' );
break;View on GitHub (pinned to fad1729dce)
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.
Example fix
// before
@Embeddable
public class Contact {
String email;
@OneToMany(mappedBy = "contact") // collection inside XML aggregate
List<Phone> phones; // -> Support for attribute mapping type not yet implemented
}
// after: keep only scalars in the aggregate
@Embeddable
public class Contact {
String email;
String primaryPhone;
} Defensive patterns
Strategy: validation
Validate before calling
static void assertXmlAggregateWritable(Class<?> embeddable) {
for (Field f : embeddable.getDeclaredFields()) {
if (f.isAnnotationPresent(ManyToOne.class) || f.isAnnotationPresent(OneToOne.class)
|| f.isAnnotationPresent(OneToMany.class) || f.isAnnotationPresent(ManyToMany.class)
|| f.isAnnotationPresent(Any.class)) {
throw new IllegalStateException(
"XML aggregate cannot serialize attribute: " + f);
}
}
} Try / catch
try {
session.persist(person); // or merge/update
} catch (UnsupportedOperationException ex) {
if (ex.getMessage() != null && ex.getMessage().startsWith("Support for attribute mapping type")) {
throw new DataMappingException("XML aggregate contains unsupported attribute type", ex);
}
throw ex;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Illegal XML content:
- XML not properly formatted:
- XML not properly formed:
- XML starts sub-object for a non-aggregate type at index %d.
- Unsupported JdbcType nested in struct:
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/d99a2b9124ccaccd.
Report an issue: GitHub.