{"record":{"id":"fc4e7d1a2ab20415","repo":"hibernate/hibernate-orm","slug":"summarization-is-not-supported-by-dbms-fc4e7d","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/HSQLLegacySqlAstTranslator.java","lineNumber":309,"sourceCode":"\t\t\t\t\trender( rhs, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\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 getDialect().getVersion().isSameOrAfter( 2, 5 );\n\t}\n\n\t@Override\n\tprotected void visitArithmeticOperand(Expression expression) {\n\t\trender( expression, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );\n\t}\n}\n","sourceCodeStart":291,"sourceCodeEnd":325,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HSQLLegacySqlAstTranslator.java#L291-L325","documentation":"The legacy HSQLDB SQL translator throws UnsupportedOperationException from renderPartitionItem() when a query's GROUP BY contains a Summarization expression (ROLLUP / GROUPING SETS). The code comment notes it could theoretically be emulated by union-ing all grouping variations, but since that must happen at the query-spec level the translator refuses the query instead of producing wrong SQL.","triggerScenarios":"Executing HQL/criteria with 'group by rollup(...)' or 'group by grouping sets(...)' on HSQLLegacyDialect; renderPartitionItem() receives the Summarization node during SQL generation and throws.","commonSituations":"Running analytics/reporting HQL originally written for Oracle or SQL Server against an HSQLDB in-memory test database; test suites that reuse production @NamedQueries; CI pipelines booting HSQLDB where rollup was never exercised locally.","solutions":["Rewrite the aggregation as explicit per-level queries combined with UNION ALL","Compute the grouping sets in Java: fetch the detailed rows and aggregate with streams, or run separate grouped queries","Use a native query for the HSQLDB test profile, or switch tests to a database whose dialect supports summarization"],"exampleFix":"// before\n\"select dept, count(e) from Employee e group by rollup(e.dept)\"\n\n// after\n\"select e.dept, count(e) from Employee e group by e.dept\" +\n\" union all \" +\n\"select null, count(e) from Employee e\"","handlingStrategy":"try-catch","validationCode":"static boolean dialectSupportsSummarization(Dialect d) {\n    return !(d instanceof HSQLLegacyDialect);\n}\nif ( !dialectSupportsSummarization(session.getJdbcServices().getDialect())\n        && hql.toLowerCase().matches(\"(?s).*(rollup|grouping\\\\s+sets)\\\\s*\\\\(.*\") ) {\n    // rewrite or skip\n}","typeGuard":"static boolean isLegacyHsqldb(Dialect d) { return d instanceof HSQLLegacyDialect; }","tryCatchPattern":"try {\n    return em.createQuery(hql, Object[].class).getResultList();\n} catch (UnsupportedOperationException e) {\n    if ( String.valueOf(e.getMessage()).contains(\"Summarization\") ) {\n        return runGroupingSetsFallback(hql); // union-all or in-memory aggregation\n    }\n    throw e;\n}","preventionTips":["Do not let production rollup queries leak into HSQLDB test profiles - maintain separate test fixtures","Centralize analytics queries behind a repository that can swap implementations per dialect","Prefer UNION ALL rewrites when the query must be truly portable"],"tags":["hibernate","hsqldb","group-by","rollup","grouping-sets","dialect"],"backgroundTag":"dialect-unsupported-sql-feature","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}