hibernate/hibernate-orm · error · HibernateException

No raw type name mapping for org.hibernate.type.SqlTypes cod

Error message

No raw type name mapping for org.hibernate.type.SqlTypes code: %s (%s)

What it means

DdlTypeRegistry.getRawTypeName(typeCode) returns the raw SQL type name used by schema validation/migration when comparing Hibernate's expected type against the actual database column type. Here the descriptor lookup succeeds, but its getRawTypeNames() returns an empty array - the built-in DdlTypeImpl derives raw names from the type name pattern and is never empty, so this happens with custom DdlType implementations - and Hibernate throws HibernateException 'No raw type name mapping for SqlTypes code'.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/spi/DdlTypeRegistry.java:279

		if ( descriptor == null ) {
			throw new HibernateException(
					String.format(
							"No type mapping for org.hibernate.type.SqlTypes code: %s (%s)",
							typeCode,
							JdbcTypeNameMapper.getTypeName( typeCode )
					)
			);
		}
		return descriptor.getTypeName( columnSize, type, this );
	}

	/**
	 * Returns the first raw SQL type name registered for the given JDBC type code.
	 */
	public String getRawTypeName(int typeCode) {
		final var rawTypeNames = getDescriptor( typeCode ).getRawTypeNames();
		if ( rawTypeNames.length == 0 ) {
			throw new HibernateException(
					String.format(
							"No raw type name mapping for org.hibernate.type.SqlTypes code: %s (%s)",
							typeCode,
							JdbcTypeNameMapper.getTypeName( typeCode )
					)
			);
		}
		return rawTypeNames[0];
	}

	/**
	 * Determines if there is a registered {@link DdlType} whose raw type name
	 * matches the given type name, taking into account DDL types registered by
	 * Hibernate.
	 *
	 * @param typeName the type name.
	 *
	 * @return {@code true} if there is a DDL type with the given raw type name

View on GitHub (pinned to fad1729dce)

Solutions

  1. Implement getRawTypeNames() in the custom DdlType to return the concrete SQL name(s) - mirror DdlTypeImpl, which derives them from the type name pattern
  2. Extend DdlTypeImpl instead of implementing DdlType from scratch so raw names come for free
  3. Skip schema validation for those columns/dialects until the contribution is fixed

Example fix

// before
class MyJsonDdlType implements DdlType {
    @Override public String[] getRawTypeNames() { return new String[0]; } // -> 'No raw type name mapping'
}

// after
class MyJsonDdlType extends DdlTypeImpl {
    MyJsonDdlType(Dialect d) { super(SqlTypes.JSON, "json", d); } // inherits non-empty raw type names
}
Defensive patterns

Strategy: validation

Validate before calling

// Unit test for every custom DdlType you contribute
for (DdlType t : myCustomDdlTypes) {
    assertTrue("DdlType for code " + t.getSqlTypeCode() + " must expose raw type names",
            t.getRawTypeNames().length > 0);
}

Prevention

When it happens

Trigger: Schema validation or migration touching a column whose registered DdlType is a hand-rolled implementation returning a zero-length array from getRawTypeNames() (only getTypeName was implemented).

Common situations: Custom DdlType contributors written against an older Hibernate API; partial copies of built-in DdlTypes; running hibernate.hbm2ddl.auto=validate after adding such a contribution.

Related errors


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