{"record":{"id":"177826b9135fd695","repo":"hibernate/hibernate-orm","slug":"summarization-is-not-supported-by-dbms-177826","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-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseAnywhereSqlAstTranslator.java","lineNumber":200,"sourceCode":"\n\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\tappendSql( \"()\" );\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}\n","sourceCodeStart":182,"sourceCodeEnd":217,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseAnywhereSqlAstTranslator.java#L182-L217","documentation":"Hibernate models ROLLUP, CUBE and GROUPING SETS groupings as a Summarization expression that renderPartitionItem must render inside GROUP BY. SQL Anywhere has no native support for these grouping constructs, and the theoretical emulation (a UNION ALL over every grouping variation) is not implemented, so the translator throws UnsupportedOperationException at render time instead of emitting invalid SQL.","triggerScenarios":"Executing HQL with SybaseAnywhereDialect such as `group by rollup(e.dept, e.role)`, `group by cube(e.dept, e.role)`, or `group by grouping sets((e.dept),(e.role))`, or the equivalent Criteria grouping-set queries.","commonSituations":"Reporting or OLAP queries ported from Oracle/SQL Server/PostgreSQL where rollup/grouping sets worked fine, then executed against a SQL Anywhere backend.","solutions":["Expand rollup/cube/grouping sets manually into a UNION ALL of the individual GROUP BY variants","Use plain GROUP BY and compute subtotals/grand totals in application code","Run the report as native SQL with a hand-written emulation","Target a database/dialect that natively supports grouping sets (Oracle, SQL Server, PostgreSQL, DB2)"],"exampleFix":"// before\nselect e.dept, e.role, count(e) from Employee e\n group by rollup(e.dept, e.role)\n\n// after\nselect e.dept, e.role, count(e) from Employee e group by e.dept, e.role\nunion all\nselect e.dept, null, count(e) from Employee e group by e.dept\nunion all\nselect null, null, count(e) from Employee e","handlingStrategy":"fallback","validationCode":"// Detect grouping-set queries before running them against dialects without support\nstatic boolean dialectSupportsSummarization(Dialect d) {\n    return !(d instanceof SybaseAnywhereDialect || d instanceof SybaseLegacyDialect\n            || d instanceof TeradataDialect || d instanceof TimesTenDialect);\n}\n// if (usesGroupingSets(hql) && !dialectSupportsSummarization(dialect)) -> use the UNION ALL variant","typeGuard":null,"tryCatchPattern":"try {\n    return runRollupQuery(hql);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Summarization\")) {\n        return runUnionAllEquivalent(hql); // pre-written UNION ALL expansion\n    }\n    throw e;\n}","preventionTips":["Treat rollup/cube/grouping sets as non-portable HQL: centralize them in per-dialect query repositories","Prefer computing subtotals in application code when the backend matrix includes Sybase/Teradata/TimesTen","Add integration tests per dialect for every analytical query"],"tags":["hibernate","sql-anywhere","grouping-sets","rollup","cube"],"backgroundTag":"grouping-sets-not-supported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}