hibernate/hibernate-orm · error · IllegalArgumentException
Unsupported user-defined type:
Error message
Unsupported user-defined type:
What it means
The standard user-defined-type exporter only knows how to render UserDefinedObjectType and UserDefinedArrayType. Any other UserDefinedType subtype reaching getSqlCreateStrings is rejected with this IllegalArgumentException naming the type. This is effectively an extension/programming error: custom code or a custom dialect supplied a UserDefinedType implementation the standard exporter cannot handle.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/tool/schema/internal/StandardUserDefinedTypeExporter.java:44
protected final Dialect dialect;
public StandardUserDefinedTypeExporter(Dialect dialect) {
this.dialect = dialect;
}
@Override
public String[] getSqlCreateStrings(
UserDefinedType userDefinedType,
Metadata metadata,
SqlStringGenerationContext context) {
if ( userDefinedType instanceof UserDefinedObjectType userDefinedObjectType ) {
return getSqlCreateStrings( userDefinedObjectType, metadata, context );
}
else if ( userDefinedType instanceof UserDefinedArrayType userDefinedArrayType ) {
return getSqlCreateStrings( userDefinedArrayType, metadata, context );
}
else {
throw new IllegalArgumentException( "Unsupported user-defined type: " + userDefinedType );
}
}
public String[] getSqlCreateStrings(
UserDefinedObjectType userDefinedType,
Metadata metadata,
SqlStringGenerationContext context) {
final var typeName = new QualifiedNameParser.NameParts(
Identifier.toIdentifier( userDefinedType.getCatalog(), userDefinedType.isCatalogQuoted() ),
Identifier.toIdentifier( userDefinedType.getSchema(), userDefinedType.isSchemaQuoted() ),
userDefinedType.getNameIdentifier()
);
try {
final String formattedTypeName = context.format( typeName );
final var createType =
new StringBuilder( "create type " )
.append( formattedTypeName )View on GitHub (pinned to fad1729dce)
Solutions
- Model custom UDTs as UserDefinedObjectType (standard CREATE TYPE shape) or UserDefinedArrayType so the standard exporter understands them.
- Override the dialect's UserDefinedTypeExporter to render your custom type kind and ensure your dialect routes export calls to it instead of the standard exporter.
- Exclude the custom type from hbm2ddl generation and create it with an external migration script.
Example fix
// before
public class MyGeometryType implements UserDefinedType { ... } // rejected by the exporter
// after
public class MyGeometryType extends UserDefinedObjectTypeImplementor { ... } // standard CREATE TYPE path Defensive patterns
Strategy: type-guard
Validate before calling
if (udt instanceof UserDefinedObjectType || udt instanceof UserDefinedArrayType) {
exporter.getSqlCreateStrings(udt, metadata, context);
} else {
// route to your dialect-specific exporter or skip hbm2ddl for this type
} Type guard
static boolean isStandardExportableUdt(UserDefinedType udt) {
return udt instanceof UserDefinedObjectType || udt instanceof UserDefinedArrayType;
} Try / catch
try {
exporter.getSqlCreateStrings(userDefinedType, metadata, context);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unsupported user-defined type:")) {
// extend UserDefinedObjectType/UserDefinedArrayType or bypass standard export for this type
} else { throw e; }
} Prevention
- Extend UserDefinedObjectType/UserDefinedArrayType rather than implementing UserDefinedType from scratch.
- Provide a dialect-specific UserDefinedTypeExporter when introducing custom UDT kinds.
- Cover custom UDT kinds with an export smoke test.
When it happens
Trigger: Passing a custom UserDefinedType implementation (neither UserDefinedObjectType nor UserDefinedArrayType) into schema export: a custom dialect or metadata contributor registering its own UDT kind, or direct programmatic calls to StandardUserDefinedTypeExporter.getSqlCreateStrings with a hand-rolled type object.
Common situations: Teams extending Hibernate 6 UDT support with internal type hierarchies; prototypes implementing UserDefinedType directly instead of extending the object/array base types; misrouted exporter usage where a dialect-specific exporter was expected to handle the call but the standard one received it.
Related errors
- Error creating SQL create commands for UDT :
- Decomposition not supported for %s
- Database does not support user-defined types (remove '@Struc
- Struct [%s] is defined by multiple components %s with differ
- Struct [%s] of class [%s] is defined by multiple components
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/98ed7c5f74c7ac40.
Report an issue: GitHub.