{"record":{"id":"b745128d7fbdcb64","repo":"hibernate/hibernate-orm","slug":"summarization-is-not-supported-by-dbms-b74512","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/HANALegacySqlAstTranslator.java","lineNumber":302,"sourceCode":"\t\t\t\t\t\tappendSql( \" not like \" );\n\t\t\t\t\t\trhs.accept( this );\n\t\t\t\t\t\treturn;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// Fall through\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\trenderComparisonStandard( lhs, operator, rhs );\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( \"grouping sets (())\" );\n\t\t}\n\t\telse if ( expression instanceof Summarization ) {\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\tprotected void renderInsertIntoNoColumns(TableInsertStandard tableInsert) {\n\t\tthrow new MappingException(\n\t\t\t\tString.format(\n\t\t\t\t\t\t\"The INSERT statement for table [%s] contains no column, and this is not supported by [%s]\",\n\t\t\t\t\t\ttableInsert.getMutatingTable().getTableId(),\n\t\t\t\t\t\tgetDialect()\n\t\t\t\t)\n\t\t);\n\t}\n\n\t@Override","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HANALegacySqlAstTranslator.java#L284-L320","documentation":"The legacy SAP HANA SQL translator (HANALegacySqlAstTranslator) throws this UnsupportedOperationException while translating an HQL/JPQL query that uses a Summarization expression, i.e. GROUP BY ROLLUP(...) or GROUP BY GROUPING SETS(...). When renderPartitionItem() meets a Summarization node it cannot render it as a partition/group-by item and fails fast during SQM-to-SQL translation instead of emitting invalid SQL.","triggerScenarios":"Executing an HQL or criteria query on HANALegacyDialect whose group-by uses rollup or grouping sets, e.g. 'select e.status, count(e.id) from Order e group by rollup(e.status)'. The translator hits the Summarization branch of renderPartitionItem() at SQL-generation time (typically on Query creation or first execution).","commonSituations":"Porting reporting/aggregation queries written for PostgreSQL/Oracle/SQLServer to HANA with the legacy dialect; upgrading to Hibernate 6.x where the legacy HANA dialect moved into the hibernate-community-dialects artifact; reusing shared @NamedQuery definitions that contain rollup across multiple databases.","solutions":["Rewrite the query without rollup/grouping sets: materialize each grouping variation and combine them with UNION ALL (the emulation the code comment suggests)","Switch the dialect to the maintained org.hibernate.dialect.HANADialect in hibernate-core (drop the 'Legacy' variant) if your HANA version and Hibernate version allow it","Run the aggregation as a native query (createNativeQuery) so the dialect's SqlAstTranslator is bypassed"],"exampleFix":"// before\nList<Object[]> rows = session.createQuery(\n    \"select e.status, count(e.id) from Order e group by rollup(e.status)\", Object[].class)\n    .getResultList();\n\n// after - emulate rollup with UNION ALL\nList<Object[]> rows = session.createQuery(\n    \"select e.status, count(e.id) from Order e group by e.status \" +\n    \"union all \" +\n    \"select null, count(e.id) from Order e\", Object[].class)\n    .getResultList();","handlingStrategy":"try-catch","validationCode":"static boolean dialectSupportsSummarization(Dialect d) {\n    return !(d instanceof HANALegacyDialect);\n}\n// gate reporting queries before execution\nif ( !dialectSupportsSummarization(session.getJdbcServices().getDialect())\n        && hql.toLowerCase().matches(\"(?s).*(rollup|grouping\\\\s+sets)\\\\s*\\\\(.*\") ) {\n    throw new IllegalArgumentException(\"rollup/grouping sets unsupported on this dialect\");\n}","typeGuard":"static boolean isLegacyHana(Dialect d) { return d instanceof HANALegacyDialect; }","tryCatchPattern":"try {\n    return session.createQuery(hql, Object[].class).getResultList();\n} catch (UnsupportedOperationException e) {\n    if ( String.valueOf(e.getMessage()).contains(\"Summarization\") ) {\n        // fall back to native SQL or a UNION ALL rewrite\n        return runSummarizationFallback(hql);\n    }\n    throw e;\n}","preventionTips":["Keep rollup/grouping sets out of shared @NamedQuery catalogs unless every target dialect supports them","Run a startup smoke test that translates all named queries against the configured dialect (SessionFactory boot validates mappings, not every query shape)","Prefer computing grouping-set style subtotals in the service layer when multiple databases must be supported"],"tags":["hibernate","sap-hana","dialect","group-by","rollup","grouping-sets"],"backgroundTag":"dialect-unsupported-sql-feature","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}