{"record":{"id":"0a8730a64da88df0","repo":"hibernate/hibernate-orm","slug":"summarization-is-not-supported-by-dbms-0a8730","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/FirebirdSqlAstTranslator.java","lineNumber":235,"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( \"'0' || '0'\" );\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 visitInListPredicate(InListPredicate inListPredicate) {\n\t\tfinal List<Expression> listExpressions = inListPredicate.getListExpressions();\n\t\tif ( listExpressions.isEmpty() ) {\n\t\t\tappendSql( \"1=\" + ( inListPredicate.isNegated() ? \"1\" : \"0\" ) );\n\t\t\treturn;\n\t\t}\n\t\tfinal Expression testExpression = inListPredicate.getTestExpression();\n\t\tif ( isParameter( testExpression ) ) {\n\t\t\trenderCasted( testExpression );\n\t\t\tif ( inListPredicate.isNegated() ) {\n\t\t\t\tappendSql( \" not\" );","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/FirebirdSqlAstTranslator.java#L217-L253","documentation":"HQL grouping-set syntax - 'group by rollup(...)', 'cube(...)', 'grouping sets(...)' - produces a Summarization AST node. FirebirdSqlAstTranslator.renderPartitionItem must render grouping expressions when Hibernate emulates aggregation/window constructs; for a Summarization it throws UnsupportedOperationException because Firebird cannot emulate the grouping variations (the comment notes the only theoretical emulation is a union of per-variation queries, which is not implemented).","triggerScenarios":"An HQL query using rollup/cube/grouping sets against Firebird, e.g. 'select cat, count(*) from Pet p group by rollup(p.kind, p.breed)', especially when the surrounding query forces partition-item rendering (window-function emulation, tuple comparisons, distinct/aggregate wrapping).","commonSituations":"OLAP-style subtotal queries written for PostgreSQL/Oracle being reused on Firebird; reporting modules that assume SQL:1999 grouping sets everywhere; test suites with a Firebird member failing only on aggregation-heavy cases.","solutions":["Replace the single rollup/cube query with an explicit GROUPING SETS emulation: run one plain group-by query per grouping variation and merge with UNION ALL in Java or native SQL","Precompute the subtotals into a summary table (via ETL or a scheduled job) and query that table on Firebird","If the analytics database can differ from the OLTP one, run rollup/cube reports on a database whose dialect supports Summarization","Drop the rollup and compute totals in the presentation layer from the detail rows"],"exampleFix":"// before (HQL, throws on Firebird)\nselect p.kind, p.breed, count(*) from Pet p group by rollup(p.kind, p.breed)\n\n// after (union of variations, native or HQL union)\nselect kind, breed, count(*) c from Pet group by kind, breed\nunion all\nselect kind, null, count(*) c from Pet group by kind\nunion all\nselect null, null, count(*) c from Pet","handlingStrategy":"validation","validationCode":"Dialect d = sessionFactory.getJdbcServices().getDialect();\nif (d instanceof FirebirdDialect && (hql.contains(\"rollup(\") || hql.contains(\"cube(\") || hql.contains(\"grouping sets\"))) {\n    hql = expandGroupingSetsToUnionAll(hql); // one plain group-by per variation\n}","typeGuard":"static boolean groupingSetsSafe(Dialect d) {\n    return !(d instanceof FirebirdDialect);\n}","tryCatchPattern":"try {\n    rows = session.createQuery(hql).getResultList(); // hql uses rollup/cube\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"Summarization\")) {\n        // re-run as union-all of plain group-by variations\n    } else throw e;\n}","preventionTips":["Treat rollup/cube/grouping sets as non-portable; wrap them behind a repository method with per-dialect implementations","Precompute subtotals for reporting on databases without grouping-set support","Add a CI job that runs every analytics query against Firebird"],"tags":["hibernate","firebird","hql","grouping-sets","rollup","cube","aggregation"],"backgroundTag":"grouping-sets-unsupported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}