{"record":{"id":"2e63ffb37fe8f497","repo":"hibernate/hibernate-orm","slug":"summarization-is-not-supported-by-dbms-2e63ff","errorCode":null,"errorMessage":"Summarization is not supported by DBMS","messagePattern":"Summarization is not supported by DBMS","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/SybaseSqlAstTranslator.java","lineNumber":287,"sourceCode":"\t@Override\n\tprotected void renderSelectTupleComparison(\n\t\t\tList<SqlSelection> lhsExpressions,\n\t\t\tSqlTuple tuple,\n\t\t\tComparisonOperator operator) {\n\t\temulateSelectTupleComparison( lhsExpressions, tuple.getExpressions(), operator, true );\n\t}\n\n\t@Override\n\tprotected void renderPartitionItem(Expression expression) {\n\t\tif ( expression instanceof Literal ) {\n\t\t\t// Note that this depends on the SqmToSqlAstConverter to add a dummy table group\n\t\t\tappendSql( \"dummy_.x\" );\n\t\t}\n\t\telse if ( expression instanceof Summarization ) {\n\t\t\t// This could theoretically be emulated by rendering all grouping variations of the query and\n\t\t\t// connect them via union all but that's probably pretty inefficient and would have to happen\n\t\t\t// on the query spec level\n\t\t\tthrow new UnsupportedOperationException( \"Summarization is not supported by DBMS\" );\n\t\t}\n\t\telse {\n\t\t\texpression.accept( this );\n\t\t}\n\t}\n\n\t@Override\n\tpublic void visitBinaryArithmeticExpression(BinaryArithmeticExpression arithmeticExpression) {\n\t\tappendSql( OPEN_PARENTHESIS );\n\t\tvisitArithmeticOperand( arithmeticExpression.getLeftHandOperand() );\n\t\tappendSql( arithmeticExpression.getOperator().getOperatorSqlTextString() );\n\t\tvisitArithmeticOperand( arithmeticExpression.getRightHandOperand() );\n\t\tappendSql( CLOSE_PARENTHESIS );\n\t}\n\n\t@Override\n\tprotected boolean needsRowsToSkip() {\n\t\treturn true;","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/SybaseSqlAstTranslator.java#L269-L305","documentation":"SybaseSqlAstTranslator.renderPartitionItem throws UnsupportedOperationException('Summarization is not supported by DBMS') when a Summarization expression (rollup/cube/grouping sets from HQL GROUP BY or window PARTITION BY) must be rendered for the SQL Anywhere dialect. Per the in-code comment, emulating it would require rendering all grouping variations of the query and connecting them with union all at the query-spec level, which is not implemented; the literal branch just above (dummy_.x) shows the kind of emulation applied to other special items instead.","triggerScenarios":"HQL 'group by rollup(...)' / 'cube(...)' / 'grouping sets(...)' or an OVER(PARTITION BY rollup(...)) item executed with SQLAnywhereDialect; fails at SQL rendering time.","commonSituations":"Running report HQL originally written for SQL Server/PostgreSQL against SQL Anywhere; cross-dialect test suites including grouping-sets queries.","solutions":["Split into one GROUP BY query per grouping level and merge in application code","Compute totals separately and combine client-side","Run grouping-sets reports on a database that supports them","Hand-write the UNION ALL expansion in native SQL if it must run on SQL Anywhere"],"exampleFix":"// before (throws on SQL Anywhere)\n\"select region, sum(amount) from Donation d group by rollup (d.region)\"\n\n// after\nbyRegion = em.createQuery(\"select region, sum(amount) ... group by region\");\ntotal = em.createQuery(\"select sum(amount) from Donation d\");","handlingStrategy":"validation","validationCode":"static boolean supportsSummarization(Dialect dialect) {\n    return !(dialect instanceof SQLAnywhereDialect || dialect instanceof SybaseASEDialect\n        || dialect instanceof HSQLDialect || dialect instanceof SpannerDialect);\n}\n\nif (usesGroupingSets(hql) && !supportsSummarization(dialect)) {\n    return expandedGrouping(query);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return em.createQuery(cubeHql, Object[].class).getResultList();\n} catch (UnsupportedOperationException e) {\n    if (\"Summarization is not supported by DBMS\".equals(e.getMessage())) {\n        return expandedGrouping(query);\n    }\n    throw e;\n}","preventionTips":["Route grouping-sets reporting away from SQL Anywhere, or implement per-level expansion","Centralize the supportsSummarization capability check and call it before every analytics query","Document dialect constraints next to each report query in the repository"],"tags":["hibernate","sql-anywhere","sybase","hql","group-by","rollup","grouping-sets"],"backgroundTag":"grouping-sets-not-supported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}