{"record":{"id":"ebfad730cd4d4359","repo":"hibernate/hibernate-orm","slug":"xml-array-in-is-not-supported-with-legac-ebfad7","errorCode":null,"errorMessage":"XML array '{}' in '{}' is not supported with legacy format enabled.","messagePattern":"XML array '(.+?)' in '(.+?)' is not supported with legacy format enabled\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/aggregate/SybaseASEAggregateSupport.java","lineNumber":121,"sourceCode":"\t\t\t\t\t\t\t\t\"strtobin(xmlextract(\" + xmlExtractArguments( aggregateParentReadExpression, columnExpression + \"/text()\" ) + \" returns varchar(16384)))\"\n\t\t\t\t\t\t);\n\t\t\t\t\tcase DATE:\n\t\t\t\t\tcase TIME:\n\t\t\t\t\tcase TIMESTAMP:\n\t\t\t\t\tcase TIMESTAMP_UTC:\n\t\t\t\t\t\t// Cast from clob to varchar first\n\t\t\t\t\t\treturn template.replace(\n\t\t\t\t\t\t\t\tplaceholder,\n\t\t\t\t\t\t\t\t\"cast(str_replace(xmlextract(\" + xmlExtractArguments( aggregateParentReadExpression, columnExpression + \"/text()\" ) + \" returns varchar(36)),'Z','') as \" + getNarrowCastTypeName( column, typeConfiguration ) + \")\"\n\t\t\t\t\t\t);\n\t\t\t\t\tcase SQLXML:\n\t\t\t\t\t\treturn template.replace(\n\t\t\t\t\t\t\t\tplaceholder,\n\t\t\t\t\t\t\t\txmlExtractForConcat( \"'<\" + XmlHelper.ROOT_TAG + \">'+\", aggregateParentReadExpression, columnExpression + \"/*\", \"+'</\" + XmlHelper.ROOT_TAG + \">'\" )\n\t\t\t\t\t\t);\n\t\t\t\t\tcase XML_ARRAY:\n\t\t\t\t\t\tif ( typeConfiguration.getCurrentBaseSqlTypeIndicators().isXmlFormatMapperLegacyFormatEnabled() ) {\n\t\t\t\t\t\t\tthrow new IllegalArgumentException( \"XML array '\" + columnExpression + \"' in '\" + aggregateParentReadExpression + \"' is not supported with legacy format enabled.\" );\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\treturn template.replace(\n\t\t\t\t\t\t\t\t\tplaceholder,\n\t\t\t\t\t\t\t\t\txmlExtractForConcat( \"'<Collection>'+\", aggregateParentReadExpression, columnExpression + \"/*\", \"+'</Collection>'\" )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\tcase CHAR:\n\t\t\t\t\tcase NCHAR:\n\t\t\t\t\tcase VARCHAR:\n\t\t\t\t\tcase NVARCHAR:\n\t\t\t\t\tcase LONG32VARCHAR:\n\t\t\t\t\tcase LONG32NVARCHAR:\n\t\t\t\t\tcase CLOB:\n\t\t\t\t\tcase NCLOB:\n\t\t\t\t\t\t// xmlextract() unfortunately does not resolve XML entities, so we use str_replace to do that\n\t\t\t\t\t\treturn template.replace(\n\t\t\t\t\t\t\t\tplaceholder,","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/aggregate/SybaseASEAggregateSupport.java#L103-L139","documentation":"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.","triggerScenarios":"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.*).","commonSituations":"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.","solutions":["Remove/turn off hibernate.type.xml_format_mapper.legacy_format so the new XML format (with Collection wrapper) is used","Keep legacy format only for persistence units that do not use XML_ARRAY aggregates on Sybase ASE","If the legacy format is mandatory, map the array as a plain String/SQLXML column and do marshalling manually"],"exampleFix":"# before (persistence.xml)\n<property name=\"hibernate.type.xml_format_mapper.legacy_format\" value=\"true\"/>\n\n# after\n<!-- property removed; default Jackson/JAXB XML format supports XML_ARRAY on ASE -->","handlingStrategy":"validation","validationCode":"// fail fast at startup instead of at first query\nif (\"true\".equalsIgnoreCase(props.getProperty(\"hibernate.type.xml_format_mapper.legacy_format\"))) {\n    if (dialect instanceof SybaseASEDialect && usesXmlArrayAggregate(entityClasses)) {\n        throw new ConfigurationException(\"legacy XML format + XML_ARRAY on ASE is unsupported\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document every persistence unit that sets hibernate.type.xml_format_mapper.legacy_format and what it excludes","Add an integration test per database backend that touches one XML aggregate read path","Prefer migrating to the default XML format mapper before adopting XML_ARRAY mappings"],"tags":["hibernate","sybase-ase","xml-array","legacy-format","aggregate-mapping"],"backgroundTag":"xml-array-legacy-format-unsupported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}