{"record":{"id":"5a272a34495d53a3","repo":"hibernate/hibernate-orm","slug":"no-column-for-interpolation-s","errorCode":null,"errorMessage":"No column for interpolation '%s'","messagePattern":"No column for interpolation '(.+?)'","errorType":"exception","errorClass":"QueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sql/internal/SQLQueryParser.java","lineNumber":279,"sourceCode":"\t\t\t}\n\t\t\taliasesFound++;\n\t\t\treturn persister.selectFragment( aliasName, suffix ) ;\n\t\t}\n\t\telse {\n\t\t\t// Let return-properties override whatever the persister has for aliases.\n\t\t\tString[] columnAliases = fieldResults.get( propertyName );\n\t\t\tif ( columnAliases == null ) {\n\t\t\t\tcolumnAliases = persister.getSubclassPropertyColumnAliases( propertyName, suffix );\n\t\t\t}\n\t\t\tvalidate( aliasName, propertyName, columnAliases, token );\n\t\t\taliasesFound++;\n\t\t\treturn columnAliases[0];\n\t\t}\n\t}\n\n\tprivate void validate(String aliasName, String propertyName, String[] columnAliases, String token) {\n\t\tif ( columnAliases == null || columnAliases.length == 0 ) {\n\t\t\tthrow new QueryException(\n\t\t\t\t\t\"No column for interpolation '%s'\"\n\t\t\t\t\t\t\t.formatted( token ),\n\t\t\t\t\toriginalQueryString\n\t\t\t);\n\t\t}\n\t\tif ( columnAliases.length != 1 ) {\n\t\t\tthrow new QueryException(\n\t\t\t\t\t\"Multiple columns for interpolation '%s' ('%s' is mapped to %s columns)\"\n\t\t\t\t\t\t\t.formatted( token, propertyName, columnAliases.length ),\n\t\t\t\t\toriginalQueryString\n\t\t\t);\n\t\t}\n\t}\n}\n","sourceCodeStart":261,"sourceCodeEnd":294,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sql/internal/SQLQueryParser.java#L261-L294","documentation":"When a legacy native query interpolates '{alias.property}', SQLQueryParser.validate checks the resolved column aliases. If the property maps to no column at all (null or empty array) it throws QueryException — the token cannot be replaced by any column name, which almost always means the property name is unknown for that alias/suffix.","triggerScenarios":"Using {e.wage} when the entity alias 'e' has no property 'wage' (typo, wrong entity, or property not included in the persister's subclass-property aliases for the mapping's suffix); referencing a property that exists on a subclass while the return maps the superclass.","commonSituations":"Typos in property names inside interpolation braces; renamed entity fields without updating native SQL; interpolating a property that is only mapped on a joined subclass; suffix mismatches after refactoring addEntity/addJoin mappings.","solutions":["Correct the property name in {alias.property} to a real mapped property of that alias's entity.","If the property lives on a subclass, map the return for the subclass alias instead.","If you need a custom column, declare it via addProperty/@FieldResult for that alias and interpolate by property name."],"exampleFix":"-- before (Employee has 'salary', not 'wage')\nselect {e.wage} from employee e\n\n-- after\nselect {e.salary} from employee e","handlingStrategy":"try-catch","validationCode":"// optional pre-check against the metamodel when you have the entity class:\nstatic boolean propertyIsMapped(org.hibernate.persister.entity.EntityPersister p, String prop) {\n    return p.getSubclassPropertyIndex(prop) >= 0; // or check property names via p.getPropertyNames()\n}","typeGuard":null,"tryCatchPattern":"try { query.list(); } catch (org.hibernate.QueryException e) { /* on 'No column for interpolation': print token, compare against entity property names, fix typo or add addProperty mapping */ throw e; }","preventionTips":["Derive {alias.prop} tokens from entity field names programmatically instead of typing them by hand.","Validate interpolation tokens against the persister's property names in a startup test."],"tags":["hibernate","native-query","interpolation","property-mapping","typo"],"backgroundTag":"unknown-property-in-native-query-interpolation","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}