{"record":{"id":"bdd125cd4338c87c","repo":"hibernate/hibernate-orm","slug":"unable-to-determine-sql-type-name-for-column-s-bdd125","errorCode":null,"errorMessage":"Unable to determine SQL type name for column '%s' of table '%s': %s","messagePattern":"Unable to determine SQL type name for column '(.+?)' of table '(.+?)': (.+?)","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/mapping/Column.java","lineNumber":334,"sourceCode":"\t\t\t\t\t\t\t\t\"Unable to determine SQL type name for column '%s' of table '%s' because there is no type mapping for org.hibernate.type.SqlTypes code: %s (%s)\",\n\t\t\t\t\t\t\t\tgetName(),\n\t\t\t\t\t\t\t\tgetValue().getTable().getName(),\n\t\t\t\t\t\t\t\tjdbcType.getDefaultSqlTypeCode(),\n\t\t\t\t\t\t\t\tJdbcTypeNameMapper.getTypeName( jdbcType.getDefaultSqlTypeCode() )\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tfinal var size = getColumnSize( dialect, mapping );\n\t\t\t\tsqlTypeName = descriptor.getTypeName( size, type, ddlTypeRegistry );\n\t\t\t\tsqlTypeLob = descriptor.isLob( size );\n\t\t\t\t// TODO: this is rubbish (could not find another way)\n\t\t\t\tif ( dialect.getAggregateSupport().useLengthsInCasts() ) {\n\t\t\t\t\tlength = size.getLength();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch ( Exception cause ) {\n\t\t\t\tthrow new MappingException(\n\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\t\t\"Unable to determine SQL type name for column '%s' of table '%s': %s\",\n\t\t\t\t\t\t\t\tgetName(),\n\t\t\t\t\t\t\t\tgetValue().getTable().getName(),\n\t\t\t\t\t\t\t\tcause.getMessage()\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcause\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn sqlTypeName;\n\t}\n\n\tprivate static Type getUnderlyingType(MappingContext mappingContext, Type type, int typeIndex) {\n\t\tif ( type instanceof ComponentType componentType ) {\n\t\t\tint cols = 0;\n\t\t\tfor ( var subtype : componentType.getSubtypes() ) {","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/mapping/Column.java#L316-L352","documentation":"Here a DdlType descriptor exists, but descriptor.getTypeName(size, type, registry) threw while building the SQL type name for the column; the original exception message is embedded in the MappingException. Typical causes are missing or illegal size information — length for character/binary types, precision/scale for numerics — that the descriptor requires.","triggerScenarios":"Character/binary columns with no length on dialects whose DdlType mandates one (SqlTypes.VARCHAR/VARBINARY variants); NUMERIC/DECIMAL without usable precision; @JdbcTypeCode coercing a value into a size-dependent DdlType; dialect aggregate-cast length handling.","commonSituations":"Hibernate 5-to-6 migration exposing previously defaulted lengths; stricter new dialects for length requirements; String or byte[] fields mapped as nationalized/binary without @Column(length = ...).","solutions":["Declare the missing size: @Column(length = ...) for character/binary types, precision/scale for numerics.","Configure dialect-wide default length/precision where supported so unmapped columns still get valid sizes.","For dialect-specific types, state the SQL type explicitly via @Column(columnDefinition = ...)."],"exampleFix":"// before\n@JdbcTypeCode(SqlTypes.VARBINARY)\nprivate byte[] payload;\n\n// after\n@JdbcTypeCode(SqlTypes.VARBINARY)\n@Column(length = 1024)\nprivate byte[] payload;","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    SessionFactory sf = configuration.buildSessionFactory();\n}\ncatch ( MappingException e ) {\n    // message: Unable to determine SQL type name for column '<col>' of table '<tbl>': <cause>\n    // add the missing length/precision to the named column\n}","preventionTips":["Always declare length on character/binary columns and precision/scale on numerics","Set dialect default length/precision where the configuration supports it","Run schema generation in CI so size errors surface before deployment"],"tags":["hibernate","ddl","column-size","dialect"],"backgroundTag":"ddl-type-resolution-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}