{"record":{"id":"bcfc359a6ff7d41e","repo":"hibernate/hibernate-orm","slug":"multiple-columns-for-interpolation-s-s-is-m","errorCode":null,"errorMessage":"Multiple columns for interpolation '%s' ('%s' is mapped to %s columns)","messagePattern":"Multiple columns for interpolation '(.+?)' \\('(.+?)' is mapped to (.+?) columns\\)","errorType":"exception","errorClass":"QueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sql/internal/SQLQueryParser.java","lineNumber":286,"sourceCode":"\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":268,"sourceCodeEnd":294,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sql/internal/SQLQueryParser.java#L268-L294","documentation":"The sibling of the no-column check: if '{alias.property}' resolves to more than one column alias (the property is a composite/embedded type or otherwise spans several columns), validate() throws QueryException. A single interpolation token can only stand for exactly one column, so multi-column properties cannot be interpolated as a unit.","triggerScenarios":"Interpolating {e.address} where Address is an embeddable mapped to several columns (street, city, zip); interpolating any property whose persister property column aliases array has length > 1, e.g. composite user types or multi-column basic types like currency+amount.","commonSituations":"Entities with @Embedded attributes referenced via legacy {alias.*}-style interpolation; migration from Hibernate 5 where multi-column interpolation was handled differently; custom UserType spanning multiple columns.","solutions":["Interpolate the single-column sub-properties instead ({e.address.street}, {e.address.city}, ...).","Or select the underlying columns directly in SQL and map them via addScalar/addProperty.","Drop interpolation for that attribute and let {alias.*} expand the whole persister fragment."],"exampleFix":"-- before (address is an @Embedded spanning street, city, zip)\nselect {e.address} from employee e\n\n-- after\nselect {e.address.street}, {e.address.city}, {e.address.zip} from employee e","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { query.list(); } catch (org.hibernate.QueryException e) { /* on 'Multiple columns for interpolation': expand {e.embedded} into its single-column sub-properties {e.embedded.a}, {e.embedded.b} */ throw e; }","preventionTips":["Never interpolate embedded/composite properties as one token — always their scalar sub-properties.","Check the persister's property column count when generating interpolation SQL."],"tags":["hibernate","native-query","interpolation","embedded-id","composite-type"],"backgroundTag":"multi-column-property-interpolation","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}