hibernate/hibernate-orm · error · MappingException

Unable to determine SQL type name for column '%s' of table '

Error message

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)

What it means

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.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/mapping/Column.java:313

			sqlTypeCode = getSqlTypeCode( mapping, getValue().getType() );
		}
		return sqlTypeCode;
	}

	private int getSqlTypeCode(MappingContext mapping, Type type) {
		return ( (BasicType<?>) getUnderlyingType( mapping, type, typeIndex ) )
				.getJdbcType()
				.getDefaultSqlTypeCode();
	}

	private String getSqlTypeName(TypeConfiguration typeConfiguration, Dialect dialect, MappingContext mapping) {
		if ( sqlTypeName == null ) {
			final var ddlTypeRegistry = typeConfiguration.getDdlTypeRegistry();
			final var type = (BasicType<?>) getUnderlyingType( mapping, getValue().getType(), typeIndex );
			final var jdbcType = type.getJdbcType();
			final var descriptor = ddlTypeRegistry.getDescriptor( jdbcType.getDdlTypeCode() );
			if ( descriptor == null ) {
				throw new MappingException(
						String.format(
								Locale.ROOT,
								"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)",
								getName(),
								getValue().getTable().getName(),
								jdbcType.getDefaultSqlTypeCode(),
								JdbcTypeNameMapper.getTypeName( jdbcType.getDefaultSqlTypeCode() )
						)
				);
			}
			try {
				final var size = getColumnSize( dialect, mapping );
				sqlTypeName = descriptor.getTypeName( size, type, ddlTypeRegistry );
				sqlTypeLob = descriptor.isLob( size );
				// TODO: this is rubbish (could not find another way)
				if ( dialect.getAggregateSupport().useLengthsInCasts() ) {
					length = size.getLength();
				}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Switch the attribute to a code the dialect supports (e.g., JSON to SqlTypes.VARCHAR/LONG32VARCHAR where appropriate).
  2. Pin an explicit @Column(columnDefinition = "jsonb") so the DdlType lookup is bypassed for DDL.
  3. Extend the dialect and register a DdlType for the code (override registerColumnTypes / contribute into the DdlTypeRegistry).

Example fix

// before: dialect has no GEOGRAPHY DdlType
@JdbcTypeCode(SqlTypes.GEOGRAPHY)
private Geometry region;

// after
@Column(columnDefinition = "geography")
@JdbcTypeCode(SqlTypes.GEOGRAPHY)
private Geometry region;
Defensive patterns

Strategy: fallback

Try / catch

try {
    SessionFactory sf = configuration.buildSessionFactory();
}
catch ( MappingException e ) {
    // message: ... no type mapping for SqlTypes code: <code> (<name>)
    // either set @Column(columnDefinition) or register a DdlType for that code in a custom dialect
}

Prevention

When it happens

Trigger: @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.

Common situations: 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.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/365685a8c56265de. Report an issue: GitHub.