{"record":{"id":"71e991d1675d8aa6","repo":"hibernate/hibernate-orm","slug":"column-unavailable-at-position","errorCode":null,"errorMessage":"Column unavailable at position: {}","messagePattern":"Column unavailable at position: (.+?)","errorType":"exception","errorClass":"CacheMetadataIncompleteException","httpStatus":null,"severity":"info","filePath":"hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/CachedJdbcValuesMetadata.java","lineNumber":54,"sourceCode":"\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 ) {\n\t\t\tthrow new CacheMetadataIncompleteException( \"Column unavailable at position: \" + position );\n\t\t}\n\t\tif ( explicitJavaType == null || type.getJavaTypeDescriptor() == explicitJavaType ) {\n\t\t\t//noinspection unchecked\n\t\t\treturn (BasicType<J>) type;\n\t\t}\n\t\telse {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/CachedJdbcValuesMetadata.java#L36-L72","documentation":"Internal signal from CachedJdbcValuesMetadata.resolveColumnName(position): the cached metadata has no recorded name for that position (the slot is null, because CapturingJdbcValuesMetadata only records columns the mapping actually consumed at cache-write time). Like error 3195 it is a CacheMetadataIncompleteException, caught in JdbcSelectExecutorStandardImpl:401 to force a fresh SQL execution instead of using the incomplete cache hit.","triggerScenarios":"A cached result set is asked for a column position that was not part of the mapping when the entry was cached; query plan evolution between cache put and hit; native query with a different column ordering than the cached entry assumed.","commonSituations":"Stale cached entries surviving a plan-relevant change (dialect upgrade, mapping change); test environments reusing a SessionFactory across schema resets; only visible if custom code bypasses the guarded path.","solutions":["No action needed in normal operation - Hibernate discards the cache hit and re-queries","Evict the query-results cache and clear the query plan cache after schema or mapping changes","Recreate the SessionFactory (restart) when the exception unexpectedly reaches application code"],"exampleFix":"// after schema/mapping change\nsessionFactory.getQueryPlanCache().clear();\nsessionFactory.getCache().evictQueryRegions();","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["No application handling required on the guarded path; the library re-executes the SQL","Evict query caches when native query column sets change between releases","Keep one Hibernate version across nodes; mixed versions poison cached metadata assumptions"],"tags":["query-cache","internal","metadata","cache-inconsistency"],"backgroundTag":"query-cache-inconsistency","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}