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': %s

What it means

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.

Source

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

								"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();
				}
			}
			catch ( Exception cause ) {
				throw new MappingException(
						String.format(
								Locale.ROOT,
								"Unable to determine SQL type name for column '%s' of table '%s': %s",
								getName(),
								getValue().getTable().getName(),
								cause.getMessage()
						),
						cause
				);
			}
		}
		return sqlTypeName;
	}

	private static Type getUnderlyingType(MappingContext mappingContext, Type type, int typeIndex) {
		if ( type instanceof ComponentType componentType ) {
			int cols = 0;
			for ( var subtype : componentType.getSubtypes() ) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Declare the missing size: @Column(length = ...) for character/binary types, precision/scale for numerics.
  2. Configure dialect-wide default length/precision where supported so unmapped columns still get valid sizes.
  3. For dialect-specific types, state the SQL type explicitly via @Column(columnDefinition = ...).

Example fix

// before
@JdbcTypeCode(SqlTypes.VARBINARY)
private byte[] payload;

// after
@JdbcTypeCode(SqlTypes.VARBINARY)
@Column(length = 1024)
private byte[] payload;
Defensive patterns

Strategy: validation

Try / catch

try {
    SessionFactory sf = configuration.buildSessionFactory();
}
catch ( MappingException e ) {
    // message: Unable to determine SQL type name for column '<col>' of table '<tbl>': <cause>
    // add the missing length/precision to the named column
}

Prevention

When it happens

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

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

Related errors


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