hibernate/hibernate-orm · error · IllegalArgumentException

XML array '{}' in '{}' is not supported with legacy format e

Error message

XML array '{}' in '{}' is not supported with legacy format enabled.

What it means

Sybase ASE has no native XML type, so Hibernate maps aggregates to text and reassembles XML with xmlextract(). For XML_ARRAY components the emulation relies on the '<Collection>' wrapper of the new (non-legacy) XML marshalling format; with the legacy oxm/xstream-style format the array layout differs and cannot be read back, so the read-expression builder refuses it.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/aggregate/SybaseASEAggregateSupport.java:121

								"strtobin(xmlextract(" + xmlExtractArguments( aggregateParentReadExpression, columnExpression + "/text()" ) + " returns varchar(16384)))"
						);
					case DATE:
					case TIME:
					case TIMESTAMP:
					case TIMESTAMP_UTC:
						// Cast from clob to varchar first
						return template.replace(
								placeholder,
								"cast(str_replace(xmlextract(" + xmlExtractArguments( aggregateParentReadExpression, columnExpression + "/text()" ) + " returns varchar(36)),'Z','') as " + getNarrowCastTypeName( column, typeConfiguration ) + ")"
						);
					case SQLXML:
						return template.replace(
								placeholder,
								xmlExtractForConcat( "'<" + XmlHelper.ROOT_TAG + ">'+", aggregateParentReadExpression, columnExpression + "/*", "+'</" + XmlHelper.ROOT_TAG + ">'" )
						);
					case XML_ARRAY:
						if ( typeConfiguration.getCurrentBaseSqlTypeIndicators().isXmlFormatMapperLegacyFormatEnabled() ) {
							throw new IllegalArgumentException( "XML array '" + columnExpression + "' in '" + aggregateParentReadExpression + "' is not supported with legacy format enabled." );
						}
						else {
							return template.replace(
									placeholder,
									xmlExtractForConcat( "'<Collection>'+", aggregateParentReadExpression, columnExpression + "/*", "+'</Collection>'" )
							);
						}
					case CHAR:
					case NCHAR:
					case VARCHAR:
					case NVARCHAR:
					case LONG32VARCHAR:
					case LONG32NVARCHAR:
					case CLOB:
					case NCLOB:
						// xmlextract() unfortunately does not resolve XML entities, so we use str_replace to do that
						return template.replace(
								placeholder,

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove/turn off hibernate.type.xml_format_mapper.legacy_format so the new XML format (with Collection wrapper) is used
  2. Keep legacy format only for persistence units that do not use XML_ARRAY aggregates on Sybase ASE
  3. If the legacy format is mandatory, map the array as a plain String/SQLXML column and do marshalling manually

Example fix

# before (persistence.xml)
<property name="hibernate.type.xml_format_mapper.legacy_format" value="true"/>

# after
<!-- property removed; default Jackson/JAXB XML format supports XML_ARRAY on ASE -->
Defensive patterns

Strategy: validation

Validate before calling

// fail fast at startup instead of at first query
if ("true".equalsIgnoreCase(props.getProperty("hibernate.type.xml_format_mapper.legacy_format"))) {
    if (dialect instanceof SybaseASEDialect && usesXmlArrayAggregate(entityClasses)) {
        throw new ConfigurationException("legacy XML format + XML_ARRAY on ASE is unsupported");
    }
}

Prevention

When it happens

Trigger: Using an @JdbcTypeCode(SqlTypes.XML_ARRAY) element inside an aggregate column on Sybase ASE while the setting hibernate.type.xml_format_mapper.legacy_format=true is enabled (set in persistence.xml, hibernate.properties, or Spring Boot spring.jpa.properties.*).

Common situations: Migrating an application from Hibernate 5/early 6.x that relied on the old XML format to a version where XML aggregates are supported on ASE; a global company-wide config that turns legacy format on for all persistence units and then someone adds an XML array aggregate on Sybase.

Related errors


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