{"record":{"id":"ab2d549160c11e3f","repo":"hibernate/hibernate-orm","slug":"cannot-dereference-an-embeddable-name","errorCode":null,"errorMessage":"Cannot dereference an embeddable name","messagePattern":"Cannot dereference an embeddable name","errorType":"exception","errorClass":"HqlInterpretationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/expression/SqmLiteralEmbeddableType.java","lineNumber":78,"sourceCode":"\tpublic void internalApplyInferableType(@Nullable SqmBindableType<?> type) {\n\t}\n\n\t@Override\n\tpublic <X> X accept(SemanticQueryWalker<X> walker) {\n\t\treturn walker.visitEmbeddableTypeLiteralExpression( this );\n\t}\n\n\t@Override\n\tpublic String asLoggableText() {\n\t\treturn \"TYPE(\" + embeddableDomainType + \")\";\n\t}\n\n\t@Override\n\tpublic SemanticPathPart resolvePathPart(\n\t\t\tString name,\n\t\t\tboolean isTerminal,\n\t\t\tSqmCreationState creationState) {\n\t\tthrow new HqlInterpretationException( \"Cannot dereference an embeddable name\" );\n\t}\n\n\t@Override\n\tpublic SqmPath<?> resolveIndexedAccess(\n\t\t\tSqmExpression<?> selector,\n\t\t\tboolean isTerminal,\n\t\t\tSqmCreationState creationState) {\n\t\tthrow new HqlInterpretationException( \"Cannot dereference an embeddable name\" );\n\t}\n\n\t@Override\n\tpublic void appendHqlString(StringBuilder hql, SqmRenderContext context) {\n\t\thql.append( embeddableDomainType.getTypeName() );\n\t}\n\n\t@Override\n\tpublic boolean equals(@Nullable Object object) {\n\t\treturn object instanceof SqmLiteralEmbeddableType<?> that","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/expression/SqmLiteralEmbeddableType.java#L60-L96","documentation":"SqmLiteralEmbeddableType is the SQM node Hibernate creates when a path segment resolves to an embeddable class name (a fully-qualified type name used as a literal). An embeddable name has no members to navigate, so resolvePathPart throws HqlInterpretationException('Cannot dereference an embeddable name') at query interpretation time.","triggerScenarios":"HQL that continues a path after an embeddable class name: select com.acme.Address.city from ..., where com.acme.Address.zip = ..., or criteria code calling resolvePathPart on an SqmLiteralEmbeddableType node.","commonSituations":"Confusing the embeddable's class name with an entity alias or identification variable; missing or typo'd aliases so Hibernate re-interprets a token as a type name; Java-style static access to embeddable fields copied into HQL.","solutions":["Navigate from an alias/root that holds an embeddable-valued attribute: select o.address.city from Order o.","If comparing types, compare type(...) results instead of dereferencing the name.","Fix the alias/typo so every path starts at an identification variable."],"exampleFix":"-- before\nselect com.acme.Address.city from Order o   -- embeddable name dereferenced\n\n-- after\nselect o.address.city from Order o           -- navigate via the embeddable attribute","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return session.createQuery( hql, Tuple.class ).getResultList();\n} catch ( org.hibernate.query.hql.HqlInterpretationException e ) {\n    // an embeddable name was dereferenced - fix the path/alias\n    throw new BadRequestException( \"Cannot dereference embeddable name in query: \" + e.getMessage(), e );\n}","preventionTips":["Start every path at an identification variable (alias), never at an embeddable class name.","Give queries explicit aliases and lint HQL for fully-qualified type names followed by a dot.","Test query interpretation separately from execution."],"tags":["hibernate","hql","embeddable","path-resolution","sqm"],"backgroundTag":"invalid-query-path","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}