{"record":{"id":"ddf3ad8fa3358f8c","repo":"hibernate/hibernate-orm","slug":"anonymous-tuple-path-source-does-not-have-a-java-m","errorCode":null,"errorMessage":"Anonymous tuple path source does not have a java member","messagePattern":"Anonymous tuple path source does not have a java member","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/tuple/internal/AnonymousTupleSqmAssociationPathSourceNew.java","lineNumber":137,"sourceCode":"\t\treturn domainType;\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic String getName() {\n\t\treturn getPathName();\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic PersistentAttributeType getPersistentAttributeType() {\n\t\treturn PersistentAttributeType.MANY_TO_ONE;\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic Member getJavaMember() {\n\t\tthrow new UnsupportedOperationException( \"Anonymous tuple path source does not have a java member\" );\n\t}\n\n\t@Override\n\tpublic boolean isAssociation() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean isCollection() {\n\t\treturn false;\n\t}\n}\n","sourceCodeStart":119,"sourceCodeEnd":150,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/tuple/internal/AnonymousTupleSqmAssociationPathSourceNew.java#L119-L150","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nMember m = attr.getJavaMember(); // UnsupportedOperationException on tuple attributes\nField f = (Field) m; // never reached\n\n// after\nif (attr instanceof AnonymousTupleSqmPathSource) {\n    Object value = tuple.get(attr.getName()); // read from the tuple result\n} else {\n    Member m = attr.getJavaMember(); // safe for real mapped attributes\n}","handlingStrategy":"type-guard","validationCode":"if (attr instanceof AnonymousTupleSqmPathSource) { value = tuple.get(attr.getName()); } else { Member m = attr.getJavaMember(); }","typeGuard":"static boolean hasJavaMember(Attribute<?, ?> a) { return !(a instanceof AnonymousTupleSqmPathSource); }","tryCatchPattern":"try { m = attr.getJavaMember(); } catch (UnsupportedOperationException e) { if (e.getMessage().contains(\"java member\")) m = null; else throw e; }","preventionTips":["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"],"tags":["hibernate","metamodel","reflection","tuple","path-source"],"backgroundTag":"anonymous-tuple-metamodel-unsupported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}