hibernate/hibernate-orm · error · MappingException
transformation of <any/> as part of <join/> (secondary-table
Error message
transformation of <any/> as part of <join/> (secondary-table) not yet implemented
What it means
A MappingException raised by HbmXmlTransformer when a <join> (secondary table) block in hbm.xml contains an <any/> mapping. Secondary-table <any/> transformation is explicitly not implemented; the Origin pinpoints the file and position.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/HbmXmlTransformer.java:4352
bootEntityInfo.getPersistentClass().getEntityName(),
hbmComponent,
componentTypeInfo
);
final var embedded = componentHandler.transformEmbedded( jaxbEmbeddable, hbmComponent, componentTypeInfo );
transferAccess(
hbmComponent.getAccess(),
embedded::setAccess,
embedded::setAttributeAccessor
);
mappingEntity.getAttributes().getEmbeddedAttributes().add( embedded );
}
else if ( hbmProperty instanceof JaxbHbmManyToOneType hbmManyToOne ) {
final var propertyInfo = bootEntityInfo.propertyInfoMap().get( hbmManyToOne.getName() );
final var jaxbManyToOne = transformManyToOne( hbmManyToOne, propertyInfo );
mappingEntity.getAttributes().getManyToOneAttributes().add( jaxbManyToOne );
}
else if ( hbmProperty instanceof JaxbHbmAnyAssociationType ) {
throw new MappingException(
"transformation of <any/> as part of <join/> (secondary-table) not yet implemented",
origin()
);
}
else if ( hbmProperty instanceof JaxbHbmDynamicComponentType ) {
handleUnsupportedContent( "<dynamic-component/> mappings not supported" );
}
}
}
}
private void transferSecondaryTable(JaxbHbmSecondaryTableType hbmJoin, JaxbEntityImpl mappingEntity) {
final var secondaryTable = new JaxbSecondaryTableImpl();
secondaryTable.setCatalog( hbmJoin.getCatalog() );
secondaryTable.setComment( hbmJoin.getComment() );
secondaryTable.setName( hbmJoin.getTable() );
secondaryTable.setSchema( hbmJoin.getSchema() );
secondaryTable.setOptional( hbmJoin.isOptional() );View on GitHub (pinned to fad1729dce)
Solutions
- Move the <any> property out of the <join> onto the entity root (main table) if the column actually lives there
- If the column truly belongs to the secondary table, keep that mapping as native hbm.xml and exclude it from transformation
- Or hand-write the mapping.xml for that entity, mapping the any-property to the secondary table
- Or remodel the any-association as a discriminator-based entity relation
Example fix
<!-- before -->
<join table="entity_ext">
<key column="entity_id"/>
<any name="owner" meta-type="string" id-type="long">
<column name="owner_type"/>
<column name="owner_id"/>
</any>
</join>
<!-- after: any moved to the entity root -->
<any name="owner" meta-type="string" id-type="long">
<column name="owner_type"/>
<column name="owner_id"/>
</any> Defensive patterns
Strategy: validation
Validate before calling
// detect <any> nested inside <join> before transforming
var joins = doc.getElementsByTagName("join");
for (int i = 0; i < joins.getLength(); i++) {
var join = (org.w3c.dom.Element) joins.item(i);
if (join.getElementsByTagName("any").getLength() > 0) {
throw new IllegalStateException("<join> '" + join.getAttribute("table") + "' contains <any/>: not transformable");
}
} Try / catch
try {
transformer.transform(hbmSource);
} catch (MappingException e) {
if (e.getMessage().contains("<any/> as part of <join/>")) {
// move the <any> to the entity root, or keep this file as native hbm.xml
}
throw e;
} Prevention
- Keep <any> properties on the entity root, not inside <join>
- Audit secondary-table blocks during migration planning
- Hand-write mapping.xml for entities whose joins carry exotic property types
When it happens
Trigger: hbm.xml containing <join table="..."> with an <any ...> property inside it, passed through the hbm-to-mapping.xml transformation. Deterministic for that construct.
Common situations: Wide legacy tables split across primary/secondary tables where a polymorphic reference landed in the secondary part; bulk migration runs stopping at the first <join> containing <any>.
Related errors
- Error transforming element-collection :
- Error transforming one-to-many :
- Error transforming many-to-many :
- Error transforming many-to-any :
- Unexpected node type -
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/91aef7b581d537e9.
Report an issue: GitHub.