{"record":{"id":"8cc30dcc6660fbd6","repo":"hibernate/hibernate-orm","slug":"column-unavailable-with-name","errorCode":null,"errorMessage":"Column unavailable with name: {}","messagePattern":"Column unavailable with name: (.+?)","errorType":"exception","errorClass":"CacheMetadataIncompleteException","httpStatus":null,"severity":"info","filePath":"hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/CachedJdbcValuesMetadata.java","lineNumber":47,"sourceCode":"\n\tpublic JavaType<?> getStoredJavaType(int columnIndex) {\n\t\tfinal var type = types[columnIndex];\n\t\treturn type != null ? type.getJavaTypeDescriptor() : null;\n\t}\n\n\t@Override\n\tpublic int getColumnCount() {\n\t\treturn columnNames.length;\n\t}\n\n\t@Override\n\tpublic int resolveColumnPosition(String columnName) {\n\t\tfor ( int i = 0; i < columnNames.length; i++ ) {\n\t\t\tif ( columnName.equalsIgnoreCase( columnNames[i] ) ) {\n\t\t\t\treturn i + 1;\n\t\t\t}\n\t\t}\n\t\tthrow new CacheMetadataIncompleteException( \"Column unavailable with name: \" + columnName );\n\t}\n\n\t@Override\n\tpublic String resolveColumnName(int position) {\n\t\tfinal String name = columnNames[position - 1];\n\t\tif ( name == null ) {\n\t\t\tthrow new CacheMetadataIncompleteException( \"Column unavailable at position: \" + position );\n\t\t}\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic <J> BasicType<J> resolveType(\n\t\t\tint position,\n\t\t\tJavaType<J> explicitJavaType,\n\t\t\tTypeConfiguration typeConfiguration) {\n\t\tfinal var type = types[position - 1];\n\t\tif ( type == null ) {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/CachedJdbcValuesMetadata.java#L29-L65","documentation":"Internal control-flow exception: CachedJdbcValuesMetadata - the result-set metadata stored alongside cached JDBC values - does not contain the requested column name. Hibernate throws CacheMetadataIncompleteException when the current result mapping needs a column the cached metadata never captured, and JdbcSelectExecutorStandardImpl (line 401) catches it and simply re-executes the query against the database. Users should essentially never see it; if it escapes to user code, the cached-results metadata is inconsistent with the query plan.","triggerScenarios":"Query-results cache entry written by a plan capturing only the columns it used, later hit by a mapping that needs an additional column; plan or dialect changed between cache put and hit (version upgrade, schema change) while stale cached results remain; only reachable via code paths outside JdbcSelectExecutorStandardImpl's guarded resolve.","commonSituations":"Rolling upgrades where nodes run different Hibernate versions against the same data; stale in-memory caches after a hot redeploy without factory restart; custom code that calls resolveColumnPosition on cached metadata directly.","solutions":["Nothing in normal operation - the library already falls back to executing the SQL","Clear the query caches: `sessionFactory.getQueryPlanCache().clear()` and evict the query-results cache region, then retry","Ensure all nodes run the same Hibernate version and restart the SessionFactory after upgrades/schema changes so caches are rebuilt consistently"],"exampleFix":"// handle unexpected escape + preventive cache clear\nsessionFactory.getQueryPlanCache().clear();\nsessionFactory.getCache().evictQueryRegions();","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat this exception as internal - Hibernate already falls back to re-executing the query","After upgrading Hibernate, dialect, or schema, clear the query plan cache and evict query cache regions","Restart the SessionFactory on deploy so in-memory cached metadata cannot outlive its plan"],"tags":["query-cache","internal","metadata","cache-inconsistency","native-query"],"backgroundTag":"query-cache-inconsistency","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}