{"record":{"id":"354c8fc7ff69a18f","repo":"hibernate/hibernate-orm","slug":"summarization-is-not-supported-by-dbms-354c8f","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/HSQLSqlAstTranslator.java","lineNumber":326,"sourceCode":"\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// HSQL has a broken 'is distinct from' operator\n\t\t\t\trenderComparisonStandard( lhs, operator, rhs );\n\t\t\t\tbreak;\n\t\t}\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\tprivate boolean supportsOffsetFetchClause() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected void visitArithmeticOperand(Expression expression) {\n\t\trender( expression, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );\n\t}\n\n}\n","sourceCodeStart":308,"sourceCodeEnd":343,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/HSQLSqlAstTranslator.java#L308-L343","documentation":"HQL supports SQL:2011 summarization -- rollup(...), cube(...) and grouping sets (...) -- as GROUP BY / partition expressions (a Summarization AST node). HSQLDB cannot express these, and the only theoretical emulation (rendering every grouping variation and chaining them with union all, per the code comment) is not implemented, so HSQLSqlAstTranslator.renderPartitionItem throws UnsupportedOperationException('Summarization is not supported by DBMS') during SQL rendering. renderPartitionItem is the shared renderer for GROUP BY items and window-function PARTITION BY items (AbstractSqlAstTranslator.visitPartitionExpressions), so the throw fires for either shape.","triggerScenarios":"Executing HQL containing 'group by rollup(e.dept, e.title)', 'group by cube(...)', 'group by grouping sets (...)', or a window function whose OVER(PARTITION BY ...) item is a Summarization, with HSQLDialect as the configured dialect. Also triggered by criteria/HQL aggregate reports that the SQM-to-SQL converter turns into Summarization nodes.","commonSituations":"Reporting queries developed against PostgreSQL/Oracle/DB2 and then executed in HSQLDB-based unit or integration tests; porting a BI-style grouped report to an HSQLDB environment; upgrading Hibernate and hitting previously-unparsed HQL that now parses into Summarization.","solutions":["Expand the summarization manually: run one plain GROUP BY query per grouping level and combine the results with union all / in-memory merging","Compute subtotals/grand totals in separate queries and assemble them in Java rather than in SQL","Run the report against a database that natively supports grouping sets (PostgreSQL, Oracle, DB2, SQL Server) instead of HSQLDB","Fall back to a native SQL query only if HSQLDB stays the target (it still lacks grouping sets, so this means manual UNION ALL SQL)"],"exampleFix":"// before (throws on HSQLDB)\nList<Object[]> rows = em.createQuery(\n    \"select d.name, count(e.id) from Employee e join e.dept d group by rollup(d.name)\",\n    Object[].class).getResultList();\n\n// after: one query per grouping level, merged in memory\ndetail = em.createQuery(\"select d.name, count(e.id) ... group by d.name\", ...).getResultList();\ntotal  = em.createQuery(\"select count(e.id) from Employee e\", ...).getResultList();","handlingStrategy":"validation","validationCode":"// Block summarization queries on dialects whose translators reject them\nstatic boolean supportsSummarization(Dialect dialect) {\n    return !(dialect instanceof HSQLDialect\n        || dialect instanceof SybaseASEDialect\n        || dialect instanceof SQLAnywhereDialect\n        || dialect instanceof SpannerDialect\n        || dialect instanceof SpannerPostgreSQLDialect);\n}\n\nif (!supportsSummarization(dialect)) {\n    return reportService.groupingExpanded(querySpec); // one query per level\n}","typeGuard":null,"tryCatchPattern":"try {\n    return em.createQuery(rollupHql, Object[].class).getResultList();\n} catch (UnsupportedOperationException e) {\n    if (\"Summarization is not supported by DBMS\".equals(e.getMessage())) {\n        return reportService.groupingExpanded(...); // fallback: per-level queries\n    }\n    throw e;\n}","preventionTips":["Avoid rollup/cube/grouping sets in shared HQL unless every target DB supports them","Keep report queries in a per-dialect repository so unsupported dialects get the expanded implementation","Add an integration test per dialect for every reporting query you ship"],"tags":["hibernate","hsqldb","hql","group-by","rollup","cube","grouping-sets","query-translation"],"backgroundTag":"grouping-sets-not-supported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}