hibernate/hibernate-orm · error · IllegalArgumentException

Exporter does not support name array types. Can't generate c

Error message

Exporter does not support name array types. Can't generate create strings for: 

What it means

StandardUserDefinedTypeExporter cannot generate CREATE statements for named array types: getSqlCreateStrings(UserDefinedArrayType) unconditionally throws this IllegalArgumentException. Dialects that do not ship their own array-UDT exporter hit it whenever a UserDefinedArrayType is present in the Metadata during schema creation.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/tool/schema/internal/StandardUserDefinedTypeExporter.java:94

			}
			createType.append( ')' );
			applyUserDefinedTypeExtensionsString( createType );

			List<String> sqlStrings = new ArrayList<>();
			sqlStrings.add( createType.toString() );
			applyComments( userDefinedType, formattedTypeName, sqlStrings );
			return sqlStrings.toArray(StringHelper.EMPTY_STRINGS);
		}
		catch (Exception e) {
			throw new MappingException( "Error creating SQL create commands for UDT : " + typeName, e );
		}
	}

	public String[] getSqlCreateStrings(
			UserDefinedArrayType userDefinedType,
			Metadata metadata,
			SqlStringGenerationContext context) {
		throw new IllegalArgumentException( "Exporter does not support name array types. Can't generate create strings for: " + userDefinedType );
	}

	/**
	 * @param udt The UDT.
	 * @param formattedTypeName The formatted UDT name.
	 * @param sqlStrings The list of SQL strings to add comments to.
	 */
	protected void applyComments(UserDefinedObjectType udt, String formattedTypeName, List<String> sqlStrings) {
		if ( dialect.supportsCommentOn() ) {
			final String comment = udt.getComment();
			if ( comment != null ) {
				sqlStrings.add( "comment on type " + formattedTypeName + " is '" + comment + "'" );
			}
			for ( var column : udt.getColumns() ) {
				final String columnComment = column.getComment();
				if ( columnComment != null ) {
					sqlStrings.add( "comment on column " + formattedTypeName + '.' + column.getQuotedName( dialect )
									+ " is '" + columnComment + "'" );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use a dialect that ships array-UDT support (e.g., OracleDialect) so a specialized exporter generates the CREATE for the array type.
  2. Re-map the attribute as a plain ARRAY/basic collection type the dialect supports natively, avoiding a named array UDT.
  3. Create the array type with an external migration script and exclude it from hbm2ddl (hibernate.hbm2ddl.auto=none or per-mapping export off).

Example fix

// before: named array UDT on a dialect whose standard exporter cannot create it
@Entity
public class Message {
    @Array(length = 10)
    @JdbcTypeCode(SqlTypes.ARRAY)
    private List<String> tags;
}

// after: plain array mapping without a named UDT
@Entity
public class Message {
    @JdbcTypeCode(SqlTypes.ARRAY)
    private List<String> tags;
}
Defensive patterns

Strategy: type-guard

Validate before calling

for (UserDefinedType udt : udtsInMetadata) {
    if (udt instanceof UserDefinedArrayType && exporterIsStandard(dialect)) {
        skipOrFailFast("array UDT " + udt + " cannot be created by the standard exporter");
    }
}

Type guard

static boolean needsDialectArrayExporter(UserDefinedType udt, Dialect dialect) {
    return udt instanceof UserDefinedArrayType
            && dialect.getUserDefinedTypeExporter().getClass() == StandardUserDefinedTypeExporter.class;
}

Try / catch

try {
    exporter.getSqlCreateStrings(userDefinedArrayType, metadata, context);
} catch (IllegalArgumentException e) {
    if (e.getMessage() != null && e.getMessage().contains("array types")) {
        // switch to an array-capable dialect, remap as plain ARRAY, or create the type via migration script
    } else { throw e; }
}

Prevention

When it happens

Trigger: Metadata contains a named array type (UserDefinedArrayType, e.g., mappings using @Array or array JDBC types that register a UDT) and schema export runs with the standard exporter/default dialect, i.e., no dialect-specific UserDefinedTypeExporter overrides array handling.

Common situations: Entity attributes mapped to named array/VARRAY types while running on a dialect without array-UDT DDL support; porting Oracle VARRAY mappings to another database; tests enabling hbm2ddl create over metadata that includes array types.

Related errors


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