{"record":{"id":"ff4c59004396fda3","repo":"hibernate/hibernate-orm","slug":"unexpected-node-type","errorCode":null,"errorMessage":"Unexpected node type - ","messagePattern":"Unexpected node type - ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/HbmXmlTransformer.java","lineNumber":2243,"sourceCode":"\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tattributes.getManyToManyAttributes().add( transformManyToMany( hbmCollection, propertyInfo ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception e) {\n\t\t\t\t\t\tthrow new TransformationException( \"Error transforming many-to-many : \" + hbmCollection.getName(), e, origin() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ( hbmCollection.getManyToAny() != null ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tattributes.getPluralAnyMappingAttributes().add( transformPluralAny( hbmCollection ) );\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception e) {\n\t\t\t\t\t\tthrow new TransformationException( \"Error transforming many-to-any : \" + hbmCollection.getName(), e, origin() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new UnsupportedOperationException( \"Unexpected node type - \" + hbmCollection );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate JaxbBasicImpl transformBasicAttribute(final JaxbHbmBasicAttributeType hbmProp, PropertyInfo propertyInfo) {\n\t\tfinal var basic = new JaxbBasicImpl();\n\t\ttransferBasicAttribute( hbmProp, basic, propertyInfo );\n\t\treturn basic;\n\t}\n\n\tprivate void transferBasicAttribute(\n\t\t\tJaxbHbmBasicAttributeType hbmProp,\n\t\t\tJaxbBasicImpl basic,\n\t\t\tPropertyInfo propertyInfo) {\n\t\tbasic.setName( hbmProp.getName() );\n\t\tbasic.setOptional( propertyInfo.bootModelProperty().isOptional() );\n\t\tbasic.setFetch( FetchType.EAGER );","sourceCodeStart":2225,"sourceCodeEnd":2261,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/HbmXmlTransformer.java#L2225-L2261","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"<!-- before: collection body is empty/truncated -->\n<set name=\"tags\" table=\"tags\">\n    <key column=\"item_id\"/>\n</set>\n\n<!-- after -->\n<set name=\"tags\" table=\"tags\">\n    <key column=\"item_id\"/>\n    <element type=\"string\" column=\"tag\"/>\n</set>","handlingStrategy":"validation","validationCode":"// every collection must contain one recognized element-type child\nvar recognized = Set.of(\"element\", \"composite-element\", \"one-to-many\", \"many-to-many\", \"many-to-any\");\nNodeList collections = doc.getElementsByTagName(\"set\"); // repeat for bag/list/map/idbag/array\nfor (int i = 0; i < collections.getLength(); i++) {\n    var c = (org.w3c.dom.Element) collections.item(i);\n    boolean ok = recognized.stream().anyMatch(c::getElementsByTagName);\n    // note: getElementsByTagName returns a list; check length > 0 in real code\n    if (!ok) throw new IllegalStateException(\"collection '\" + c.getAttribute(\"name\") + \"' has no recognized element child\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    transformer.transform(hbmSource);\n} catch (UnsupportedOperationException e) {\n    // message contains the offending node's toString - use it to locate the broken collection\n    log.error(\"malformed collection: {}\", e.getMessage());\n    throw e;\n}","preventionTips":["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"],"tags":["hibernate","hbm-xml","collection-mapping","mapping-transformation","malformed-xml"],"backgroundTag":"unsupported-orm-mapping-feature","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}