hibernate/hibernate-orm · error · UnsupportedOperationException
Unexpected node type -
Error message
Unexpected node type -
What it means
Thrown by HbmXmlTransformer when a plural attribute mapping (PluralAttributeInfo) contains none of the recognized collection-body elements: no <element>/<composite-element>, no <one-to-many>, no <many-to-many>, no <many-to-any>. The message appends the collection node's toString, which identifies the offending property.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/HbmXmlTransformer.java:2243
}
else {
attributes.getManyToManyAttributes().add( transformManyToMany( hbmCollection, propertyInfo ) );
}
}
catch (Exception e) {
throw new TransformationException( "Error transforming many-to-many : " + hbmCollection.getName(), e, origin() );
}
}
else if ( hbmCollection.getManyToAny() != null ) {
try {
attributes.getPluralAnyMappingAttributes().add( transformPluralAny( hbmCollection ) );
}
catch (Exception e) {
throw new TransformationException( "Error transforming many-to-any : " + hbmCollection.getName(), e, origin() );
}
}
else {
throw new UnsupportedOperationException( "Unexpected node type - " + hbmCollection );
}
}
}
}
private JaxbBasicImpl transformBasicAttribute(final JaxbHbmBasicAttributeType hbmProp, PropertyInfo propertyInfo) {
final var basic = new JaxbBasicImpl();
transferBasicAttribute( hbmProp, basic, propertyInfo );
return basic;
}
private void transferBasicAttribute(
JaxbHbmBasicAttributeType hbmProp,
JaxbBasicImpl basic,
PropertyInfo propertyInfo) {
basic.setName( hbmProp.getName() );
basic.setOptional( propertyInfo.bootModelProperty().isOptional() );
basic.setFetch( FetchType.EAGER );View on GitHub (pinned to fad1729dce)
Solutions
- Locate the collection named in the message ('Unexpected node type - ' + node toString) in the hbm file named by the Origin
- Add the missing element/composite-element/one-to-many/many-to-many/many-to-any child to the collection
- Validate the file against the hibernate-mapping XSD to catch other structural damage
- Restore the file from version control if it was truncated or badly merged
Example fix
<!-- before: collection body is empty/truncated -->
<set name="tags" table="tags">
<key column="item_id"/>
</set>
<!-- after -->
<set name="tags" table="tags">
<key column="item_id"/>
<element type="string" column="tag"/>
</set> Defensive patterns
Strategy: validation
Validate before calling
// every collection must contain one recognized element-type child
var recognized = Set.of("element", "composite-element", "one-to-many", "many-to-many", "many-to-any");
NodeList collections = doc.getElementsByTagName("set"); // repeat for bag/list/map/idbag/array
for (int i = 0; i < collections.getLength(); i++) {
var c = (org.w3c.dom.Element) collections.item(i);
boolean ok = recognized.stream().anyMatch(c::getElementsByTagName);
// note: getElementsByTagName returns a list; check length > 0 in real code
if (!ok) throw new IllegalStateException("collection '" + c.getAttribute("name") + "' has no recognized element child");
} Try / catch
try {
transformer.transform(hbmSource);
} catch (UnsupportedOperationException e) {
// message contains the offending node's toString - use it to locate the broken collection
log.error("malformed collection: {}", e.getMessage());
throw e;
} Prevention
- Schema-validate hbm files (hibernate-mapping XSD) before transformation - it catches incomplete collections
- Review merges that touch collection blocks
- Keep mappings in version control and diff after bulk edits
When it happens
Trigger: An hbm.xml collection element (<set>, <bag>, <list>, <map>, <idbag>, <array>) whose body lacks every recognized element type - typically a truncated or hand-edited file, or exotic content that slipped past schema validation.
Common situations: Truncated mapping files from failed merges or copy-paste; collections whose element was commented out; XML that was never validated against the hbm-mapping XSD.
Related errors
- Duplicate collection definition '%s'
- Error transforming element-collection :
- Error transforming one-to-many :
- Error transforming many-to-many :
- Error transforming many-to-any :
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/ff4c59004396fda3.
Report an issue: GitHub.