{"record":{"id":"86e8b680496c9ecf","repo":"hibernate/hibernate-orm","slug":"error-transforming-one-to-many","errorCode":null,"errorMessage":"Error transforming one-to-many : ","messagePattern":"Error transforming one-to-many : ","errorType":"exception","errorClass":"TransformationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/HbmXmlTransformer.java","lineNumber":2218,"sourceCode":"\t\t\t\t\tthrow new TransformationException( \"Error transforming <any/> : \" + any.getName(), e, origin() );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( hbmAttributeMapping instanceof PluralAttributeInfo hbmCollection ) {\n\t\t\t\tfinal var propertyInfo = managedTypeInfo.propertyInfoMap().get( hbmCollection.getName() );\n\t\t\t\tif ( hbmCollection.getElement() != null || hbmCollection.getCompositeElement() != null ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tattributes.getElementCollectionAttributes().add( transformElementCollection( roleBase, hbmCollection, propertyInfo ) );\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 element-collection : \" + hbmCollection.getName(), e, origin() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ( hbmCollection.getOneToMany() != null ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tattributes.getOneToManyAttributes().add( transformOneToMany( hbmCollection, propertyInfo ) );\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 one-to-many : \" + hbmCollection.getName(), e, origin() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ( hbmCollection.getManyToMany() != null ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif ( hbmCollection.getManyToMany().isUnique() ) {\n\t\t\t\t\t\t\tattributes.getOneToManyAttributes().add( transformManyToManyToOneToMany( hbmCollection, propertyInfo ) );\n\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 ) );","sourceCodeStart":2200,"sourceCodeEnd":2236,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/HbmXmlTransformer.java#L2200-L2236","documentation":"Thrown by HbmXmlTransformer when transformOneToMany fails for a collection declared with <one-to-many/>. It is a wrapper: the underlying exception (usually an unresolvable target entity or bad join configuration) is chained, and the Origin of the mapping is recorded. The message names the collection property that failed.","triggerScenarios":"Transforming an hbm.xml where a plural attribute has a <one-to-many class=\"...\"> child and the referenced entity class is not on the classpath, is not part of the mapped set, or the boot model's property info for the collection is missing/inconsistent.","commonSituations":"Legacy parent/child hbm.xml sets where the child entity mapping file is not loaded in the same transformation run; renamed entity classes after a refactor; hbm files transformed in isolation rather than as the full unit.","solutions":["Read exception.getCause() to get the concrete failure before touching anything","Ensure the class named in <one-to-many class=\"...\"> exists and its own mapping is included in the same metadata/transformation run","Check the collection property name on the entity matches the hbm 'name' attribute","Fix the reference or mapping and re-run transformation","Keep the mapping as native hbm.xml if the transformer cannot express it"],"exampleFix":"<!-- before -->\n<set name=\"items\" inverse=\"true\">\n    <key column=\"order_id\"/>\n    <one-to-many class=\"com.acme.OrderItemTypo\"/>\n</set>\n\n<!-- after -->\n<set name=\"items\" inverse=\"true\">\n    <key column=\"order_id\"/>\n    <one-to-many class=\"com.acme.OrderItem\"/>\n</set>","handlingStrategy":"try-catch","validationCode":"// verify the one-to-many target is part of the same mapping set before transform\nSet<String> mappedClasses = hbmFiles.stream()\n        .map(f -> rootEntityClassNameOf(f))\n        .collect(Collectors.toSet());\nString target = oneToManyClassAttrOf(hbmFile, \"items\");\nif (!mappedClasses.contains(target)) throw new IllegalStateException(\"<one-to-many> target not in mapping set: \" + target);","typeGuard":null,"tryCatchPattern":"try {\n    transformer.transform(hbmSource);\n} catch (TransformationException e) {\n    log.error(\"one-to-many transform failed: {}\", e.getMessage(), e.getCause());\n    // inspect e.getCause(): typically ClassNotFound / unknown entity for the target class\n    throw e;\n}","preventionTips":["Transform the whole mapping unit, never single files that reference other entities","After entity renames, grep hbm files for one-to-many class attributes","Log the cause chain, not just the wrapper message"],"tags":["hibernate","hbm-xml","one-to-many","mapping-transformation","orm"],"backgroundTag":"orm-mapping-transformation-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}