hibernate/hibernate-orm · error · UnsupportedOperationException
Anonymous tuple path source does not have a java member
Error message
Anonymous tuple path source does not have a java member
What it means
AnonymousTupleSqmAssociationPathSource represents an association attribute of a tuple-typed result (CTE, dynamic instantiation). Because the attribute is synthetic — it has no backing field or getter — getJavaMember() always throws UnsupportedOperationException. JPA metamodel code that expects a reflection Member (Field/Method) cannot work on tuple-derived attributes.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/sqm/tuple/internal/AnonymousTupleSqmAssociationPathSourceNew.java:137
return domainType;
}
@Override
@Nonnull
public String getName() {
return getPathName();
}
@Override
@Nonnull
public PersistentAttributeType getPersistentAttributeType() {
return PersistentAttributeType.MANY_TO_ONE;
}
@Override
@Nonnull
public Member getJavaMember() {
throw new UnsupportedOperationException( "Anonymous tuple path source does not have a java member" );
}
@Override
public boolean isAssociation() {
return true;
}
@Override
public boolean isCollection() {
return false;
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Check 'attribute instanceof AnonymousTupleSqmPathSource' and skip getJavaMember() for such synthetic attributes
- Resolve Java members against the real entity metamodel (EntityManagerFactory.getMetamodel()), not against tuple query attribute sources
- Access tuple values positionally/by name from the query result (Tuple.get(...)) instead of reflectively via members
Example fix
// before
Member m = attr.getJavaMember(); // UnsupportedOperationException on tuple attributes
Field f = (Field) m; // never reached
// after
if (attr instanceof AnonymousTupleSqmPathSource) {
Object value = tuple.get(attr.getName()); // read from the tuple result
} else {
Member m = attr.getJavaMember(); // safe for real mapped attributes
} Defensive patterns
Strategy: type-guard
Validate before calling
if (attr instanceof AnonymousTupleSqmPathSource) { value = tuple.get(attr.getName()); } else { Member m = attr.getJavaMember(); } Type guard
static boolean hasJavaMember(Attribute<?, ?> a) { return !(a instanceof AnonymousTupleSqmPathSource); } Try / catch
try { m = attr.getJavaMember(); } catch (UnsupportedOperationException e) { if (e.getMessage().contains("java member")) m = null; else throw e; } Prevention
- Read tuple values via Tuple.get(name), never via reflection on attributes
- Skip getJavaMember() for synthetic tuple attributes in generic mappers
- Keep reflection-based mapping utilities constrained to real entity metamodel types
When it happens
Trigger: Calling getJavaMember() on an Attribute/PathSource obtained from a tuple-typed query result — annotation scanners, mapping validators, and reflective accessors that resolve attributes to Java members.
Common situations: Audit/serialization frameworks that call attribute.getJavaMember() to read or write values; Spring-like mapping utilities walking attributes; applying generic JPA metamodel tooling to Hibernate CTE or select-new queries.
Related errors
- Anonymous tuple path source does not have a declaring type
- Could not instantiate event listener '{}'
- Unable to instantiate StatementObserver - {}
- Could not instantiate named strategy class [{}]
- Could not instantiate named strategy class [%s]
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/ddf3ad8fa3358f8c.
Report an issue: GitHub.