{"record":{"id":"328bdc5a35efbbba","repo":"hibernate/hibernate-orm","slug":"unsupported-aggregate-sql-type-328bdc","errorCode":null,"errorMessage":"Unsupported aggregate SQL type: {}","messagePattern":"Unsupported aggregate SQL type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/aggregate/SybaseASEAggregateSupport.java","lineNumber":157,"sourceCode":"\t\t\t\t\t\t\t\tplaceholder,\n\t\t\t\t\t\t\t\t\"cast(str_replace(str_replace(str_replace(str_replace(xmlextract(\" + xmlExtractArguments( aggregateParentReadExpression, columnExpression + \"/text()\" ) + \" returns varchar(16384)),'&lt;','<'),'&gt;','>'),'&quot;','\\\"'),'&amp;','&') as \" + getNarrowCastTypeName( column, typeConfiguration ) + \")\"\n\t\t\t\t\t\t);\n\t\t\t\t\tcase UUID:\n\t\t\t\t\t\tif ( SqlTypes.isBinaryType( column.getJdbcMapping().getJdbcType().getDdlTypeCode() ) ) {\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\t\"strtobin(str_replace(xmlextract(\" + xmlExtractArguments( aggregateParentReadExpression, columnExpression + \"/text()\" ) + \" returns varchar(36)),'-',null))\"\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Fall-through intended\n\t\t\t\t\tdefault:\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(xmlextract(\" + xmlExtractArguments( aggregateParentReadExpression, columnExpression + \"/text()\" ) + \" returns varchar(16384)) as \" + getNarrowCastTypeName( column, typeConfiguration ) + \")\"\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t}\n\t\tthrow new IllegalArgumentException( \"Unsupported aggregate SQL type: \" + aggregateColumnTypeCode );\n\t}\n\n\tprivate static String xmlExtractArguments(String aggregateParentReadExpression, String xpathFragment) {\n\t\tfinal String extractArguments;\n\t\tfinal int separatorIndex;\n\t\tfinal int patternIdx;\n\t\tif ( aggregateParentReadExpression.startsWith( XML_EXTRACT_READ_START )\n\t\t\t&& aggregateParentReadExpression.endsWith( XML_EXTRACT_READ_END )\n\t\t\t&& (patternIdx = aggregateParentReadExpression.indexOf( XML_EXTRACT_READ_NULL_CHECK )) != -1\n\t\t\t&& aggregateParentReadExpression.regionMatches( patternIdx + XML_EXTRACT_READ_NULL_CHECK.length(),\n\t\t\t\tXML_EXTRACT_READ_INVOCATION_START, 0, XML_EXTRACT_READ_INVOCATION_START.length() )) {\n\t\t\tfinal int argumentsStartIndex = patternIdx + XML_EXTRACT_READ_NULL_CHECK.length() + XML_EXTRACT_READ_INVOCATION_START.length();\n\t\t\tseparatorIndex = aggregateParentReadExpression.indexOf( XML_EXTRACT_SEPARATOR );\n\t\t\tfinal var sb = new StringBuilder( aggregateParentReadExpression.length() - argumentsStartIndex + xpathFragment.length() );\n\t\t\tsb.append( aggregateParentReadExpression, argumentsStartIndex, separatorIndex );\n\t\t\tsb.append( '/' );\n\t\t\tsb.append( xpathFragment );\n\t\t\tsb.append( aggregateParentReadExpression, separatorIndex + 2, aggregateParentReadExpression.length() - XML_EXTRACT_READ_END.length() );","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/aggregate/SybaseASEAggregateSupport.java#L139-L175","documentation":"This is the fall-through of SybaseASEAggregateSupport.aggregateComponentExpression(): after the big switch over the component's JDBC type code, any code not handled (e.g. ARRAY, DISTINCT, NULL types) cannot be extracted out of the XML aggregate with ASE's xmlextract-based emulation, so mapping validation fails fast.","triggerScenarios":"An embeddable used inside an @JdbcTypeCode(SqlTypes.SQLXML or XML_ARRAY) aggregate that contains a field of an unhandled JDBC type — e.g. an int[]/@JdbcTypeCode(SqlTypes.INTEGER_ARRAY) member, or an exotic type like SqlTypes.NULL — on Sybase ASE.","commonSituations":"Porting an entity with array-typed embeddable members from PostgreSQL to Sybase; adding a new array field to an existing XML aggregate and having the ASE schema export or first query fail during bootstrap.","solutions":["Remove or replace the array/exotic-typed member inside the XML aggregate embeddable (e.g. store the array as a JSON String member and deserialize in code)","Move the array member out of the aggregate into its own column","Use a dialect whose aggregate support handles that component type (PostgreSQL with native jsonb/xml)"],"exampleFix":"// before\n@Embeddable\nclass Meta {\n    @JdbcTypeCode(SqlTypes.INTEGER_ARRAY)\n    List<Integer> tags; // unsupported component inside XML aggregate on ASE\n}\n\n// after\n@Embeddable\nclass Meta {\n    String tagsJson; // serialize/deserialize via Jackson in accessors\n}","handlingStrategy":"validation","validationCode":"// static check of embeddable members used inside XML aggregates on ASE\nfor (Field f : embeddableClass.getDeclaredFields()) {\n    JdbcTypeCode t = f.getAnnotation(JdbcTypeCode.class);\n    int code = t != null ? t.value() : -1;\n    if (code == SqlTypes.ARRAY || code == SqlTypes.INTEGER_ARRAY || code == SqlTypes.VARCHAR_ARRAY) {\n        if (targetDialectIsAse) throw new IllegalStateException(\"Array member in XML aggregate unsupported on ASE: \" + f);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer String-encoded JSON members for collections inside XML aggregates when targeting multiple databases","Run schema validation (hibernate.hbm2ddl.auto=validate) in CI against ASE to surface mapping issues at build time"],"tags":["hibernate","sybase-ase","aggregate-mapping","xml","array-type"],"backgroundTag":"unsupported-aggregate-sql-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}