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

  1. Check 'attribute instanceof AnonymousTupleSqmPathSource' and skip getJavaMember() for such synthetic attributes
  2. Resolve Java members against the real entity metamodel (EntityManagerFactory.getMetamodel()), not against tuple query attribute sources
  3. 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

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


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/ddf3ad8fa3358f8c. Report an issue: GitHub.