{"record":{"id":"365685a8c56265de","repo":"hibernate/hibernate-orm","slug":"unable-to-determine-sql-type-name-for-column-s","errorCode":null,"errorMessage":"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)","messagePattern":"Unable to determine SQL type name for column '(.+?)' of table '(.+?)' because there is no type mapping for org\\.hibernate\\.type\\.SqlTypes code: (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/mapping/Column.java","lineNumber":313,"sourceCode":"\t\t\tsqlTypeCode = getSqlTypeCode( mapping, getValue().getType() );\n\t\t}\n\t\treturn sqlTypeCode;\n\t}\n\n\tprivate int getSqlTypeCode(MappingContext mapping, Type type) {\n\t\treturn ( (BasicType<?>) getUnderlyingType( mapping, type, typeIndex ) )\n\t\t\t\t.getJdbcType()\n\t\t\t\t.getDefaultSqlTypeCode();\n\t}\n\n\tprivate String getSqlTypeName(TypeConfiguration typeConfiguration, Dialect dialect, MappingContext mapping) {\n\t\tif ( sqlTypeName == null ) {\n\t\t\tfinal var ddlTypeRegistry = typeConfiguration.getDdlTypeRegistry();\n\t\t\tfinal var type = (BasicType<?>) getUnderlyingType( mapping, getValue().getType(), typeIndex );\n\t\t\tfinal var jdbcType = type.getJdbcType();\n\t\t\tfinal var descriptor = ddlTypeRegistry.getDescriptor( jdbcType.getDdlTypeCode() );\n\t\t\tif ( descriptor == null ) {\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' 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}","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/mapping/Column.java#L295-L331","documentation":"Computing the DDL type for a column looks up a DdlType by jdbcType.getDdlTypeCode() in the DdlTypeRegistry. If the active dialect never contributed a descriptor for that code (descriptor == null), Hibernate cannot render the SQL type and throws MappingException, naming the column, table, the SqlTypes code, and its readable name.","triggerScenarios":"@JdbcTypeCode(SqlTypes.GEOGRAPHY) or other exotic codes on a dialect without a matching DdlType; @JdbcTypeCode(SqlTypes.JSON) on a pre-2016 SQL Server dialect; custom JdbcType whose getDdlTypeCode() has no registered descriptor; schema export/validation run against such a mapping.","commonSituations":"Using spatial, JSON, UUID, or ARRAY columns with a dialect version lacking support; porting mappings between databases; introducing custom JDBC types without registering their DDL counterpart.","solutions":["Switch the attribute to a code the dialect supports (e.g., JSON to SqlTypes.VARCHAR/LONG32VARCHAR where appropriate).","Pin an explicit @Column(columnDefinition = \"jsonb\") so the DdlType lookup is bypassed for DDL.","Extend the dialect and register a DdlType for the code (override registerColumnTypes / contribute into the DdlTypeRegistry)."],"exampleFix":"// before: dialect has no GEOGRAPHY DdlType\n@JdbcTypeCode(SqlTypes.GEOGRAPHY)\nprivate Geometry region;\n\n// after\n@Column(columnDefinition = \"geography\")\n@JdbcTypeCode(SqlTypes.GEOGRAPHY)\nprivate Geometry region;","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    SessionFactory sf = configuration.buildSessionFactory();\n}\ncatch ( MappingException e ) {\n    // message: ... no type mapping for SqlTypes code: <code> (<name>)\n    // either set @Column(columnDefinition) or register a DdlType for that code in a custom dialect\n}","preventionTips":["Test schema export for every @JdbcTypeCode against each target dialect","Register DdlTypes for custom JDBC types together with the types themselves","Document which SQL type codes each supported database handles"],"tags":["hibernate","dialect","ddl","jdbc-type","schema"],"backgroundTag":"missing-type-mapping","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}