hibernate/hibernate-orm · error · UnsupportedOperationException
Join fetching an @Any association is not supported for entit
Error message
Join fetching an @Any association is not supported for entity '%s' because it does not use a basic identifier
What it means
Error "Join fetching an @Any association is not supported for entity '%s' because it does not use a basic identifier" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/DiscriminatedAssociationMapping.java:523
auxiliaryMapping.applyPredicate(
entityMappingType,
predicateCollector::applyPredicate,
entityTableGroup,
creationState.getSqlAliasBaseGenerator(),
creationState.getLoadQueryInfluencers()
);
}
}
private Predicate createAssociationPredicate(
TableGroup lhs,
TableGroup entityTableGroup,
EntityMappingType entityMappingType,
DiscriminatorValueDetails valueDetail) {
final var identifierMapping = entityMappingType.getIdentifierMapping();
final BasicValuedModelPart identifierPart = identifierMapping.asBasicValuedModelPart();
if ( identifierPart == null ) {
throw new UnsupportedOperationException(
"Join fetching an @Any association is not supported for entity '" + entityMappingType.getEntityName()
+ "' because it does not use a basic identifier"
);
}
final TableReference discriminatorTableReference =
lhs.resolveTableReference( null, discriminatorPart.getContainingTableExpression() );
final TableReference keyTableReference =
lhs.resolveTableReference( null, keyPart.getContainingTableExpression() );
final TableReference identifierTableReference =
entityTableGroup.resolveTableReference( entityTableGroup.getNavigablePath(), identifierPart.getContainingTableExpression() );
final Junction predicate = new Junction( Junction.Nature.CONJUNCTION );
predicate.add(
new ComparisonPredicate(
new ColumnReference( discriminatorTableReference, discriminatorPart ),
EQUAL,
new QueryLiteral<>( valueDetail.getValue(), discriminatorPart )View on GitHub (pinned to fad1729dce)
Solutions
- Remove the join fetch on the @Any association; load it lazily or with a select fetch.
- Use an entity with a basic (single-column) identifier for join-fetched any-associations.
When it happens
Trigger: Thrown when a join fetch is requested on an @Any association whose target entity uses a non-basic (composite) identifier.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/245aa477692cad4f.
Report an issue: GitHub.