{"record":{"id":"36d3959a3033348b","repo":"hibernate/hibernate-orm","slug":"unable-to-resolve-hibernate-type-for-column-s-o","errorCode":null,"errorMessage":"Unable to resolve Hibernate type for column '%s' of table '%s'","messagePattern":"Unable to resolve Hibernate type for column '(.+?)' of table '(.+?)'","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/mapping/Column.java","lineNumber":487,"sourceCode":"\t\t\tif ( typeStartIndex + columnSpan > typeIndex ) {\n\t\t\t\tfinal int subtypeIndex = typeIndex - typeStartIndex;\n\t\t\t\tif ( subtype instanceof EntityType ) {\n\t\t\t\t\treturn getTypeForEntityValue( mappingContext, subtype, subtypeIndex );\n\t\t\t\t}\n\t\t\t\telse if ( subtype instanceof ComponentType componentType ) {\n\t\t\t\t\treturn getTypeForComponentValue( mappingContext, componentType, subtypeIndex );\n\t\t\t\t}\n\t\t\t\telse if ( subtypeIndex == 0 ) {\n\t\t\t\t\treturn subtype;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttypeStartIndex += columnSpan;\n\t\t}\n\n\t\tthrow new MappingException(\n\t\t\t\tString.format(\n\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\"Unable to resolve Hibernate type for column '%s' of table '%s'\",\n\t\t\t\t\t\tgetName(),\n\t\t\t\t\t\tgetValue().getTable().getName()\n\t\t\t\t)\n\t\t);\n\t}\n\n\tprivate Type getTypeForEntityValue(MappingContext mappingContext, Type type, int typeIndex) {\n\t\tint index = 0;\n\t\tif ( type instanceof EntityType entityType ) {\n\t\t\treturn getTypeForEntityValue(\n\t\t\t\t\tmappingContext,\n\t\t\t\t\tentityType.getIdentifierOrUniqueKeyType( mappingContext ),\n\t\t\t\t\ttypeIndex\n\t\t\t);\n\t\t}","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/mapping/Column.java#L469-L505","documentation":"To resolve a column's Hibernate type, Column walks the owning value's type, accumulating each sub-type's column span to find which sub-type covers the given column index. When the spans never cover the column — an extra column or formula inside a component, a wrong typeIndex, or misordered multi-column types — resolution fails with this MappingException naming the column and table.","triggerScenarios":"A component/embeddable mapping with more <column>/<formula> entries than the component's types span; @Columns on a multi-column custom type in the wrong position relative to typeIndex; formulas inside composite elements offsetting spans; generated mappings emitting stale column lists.","commonSituations":"Hand-maintained hbm components; switching an attribute between a basic type and a multi-column custom type; code generators that do not regenerate join column lists after model changes.","solutions":["Make each component sub-mapping declare exactly the columns its type spans, in order.","Remove stray columns or formulas that no sub-type owns.","For multi-column custom types, order @Columns entries to match the type's column order."],"exampleFix":"<!-- before: extra selectable with no type span -->\n<component name=\"addr\">\n    <property name=\"zip\" column=\"zip\"/>\n    <formula>upper(street)</formula>\n</component>\n\n<!-- after -->\n<component name=\"addr\">\n    <property name=\"zip\" column=\"zip\"/>\n    <property name=\"street\" column=\"street\"/>\n</component>","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    SessionFactory sf = configuration.buildSessionFactory();\n}\ncatch ( MappingException e ) {\n    // message: Unable to resolve Hibernate type for column '<col>' of table '<tbl>'\n    // check that every column inside the owning component is covered by a sub-type span\n}","preventionTips":["Declare columns in the exact order of the owning type's column spans","Remove orphan columns/formulas when changing component fields","Prefer annotations over hand-written hbm components to keep spans consistent"],"tags":["hibernate","mapping","component","column"],"backgroundTag":"unresolved-column-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}