hibernate/hibernate-orm · error · UnsupportedOperationException
Summarization is not supported by DBMS
Error message
Summarization is not supported by DBMS
What it means
HQL grouping-set constructs - 'group by rollup(...)', 'cube(...)', 'grouping sets(...)' - become a Summarization AST node. H2LegacySqlAstTranslator.renderPartitionItem must render such expressions when emulating aggregate/window machinery, and for Summarization it throws UnsupportedOperationException: the legacy H2 translator contains no grouping-sets emulation (the source comment notes only an impractical union-all rewrite exists).
Source
Thrown at hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacySqlAstTranslator.java:300
if ( renderAsArray ) {
append( OPEN_PARENTHESIS );
}
super.visitSqlSelections( selectClause );
if ( renderAsArray ) {
append( CLOSE_PARENTHESIS );
}
}
@Override
protected void renderPartitionItem(Expression expression) {
if ( expression instanceof Literal ) {
appendSql( "'0' || '0'" );
}
else if ( expression instanceof Summarization ) {
// This could theoretically be emulated by rendering all grouping variations of the query and
// connect them via union all but that's probably pretty inefficient and would have to happen
// on the query spec level
throw new UnsupportedOperationException( "Summarization is not supported by DBMS" );
}
else {
expression.accept( this );
}
}
@Override
public void visitBinaryArithmeticExpression(BinaryArithmeticExpression arithmeticExpression) {
appendSql( OPEN_PARENTHESIS );
visitArithmeticOperand( arithmeticExpression.getLeftHandOperand() );
appendSql( arithmeticExpression.getOperator().getOperatorSqlTextString() );
visitArithmeticOperand( arithmeticExpression.getRightHandOperand() );
appendSql( CLOSE_PARENTHESIS );
}
@Override
protected void visitArithmeticOperand(Expression expression) {
render( expression, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );View on GitHub (pinned to fad1729dce)
Solutions
- Expand the rollup/cube into an explicit UNION ALL of plain group-by queries (one per grouping variation)
- Switch the H2 database to the non-legacy dialect (H2 2.x), which supports grouping-set rendering
- Precompute subtotals (summary table or in-Java aggregation over detail rows)
- Branch the report query per database and use plain group-by on the H2 legacy profile
Example fix
// before (HQL, throws on H2 legacy dialect) select d.name, count(e) from Employee e join e.dept d group by rollup(d.name) // after (explicit union of variations) select d.name, count(e) from Employee e join e.dept d group by d.name union all select null, count(e) from Employee e
Defensive patterns
Strategy: validation
Validate before calling
Dialect d = sessionFactory.getJdbcServices().getDialect();
if (d instanceof org.hibernate.community.dialect.H2LegacyDialect
&& (hql.contains("rollup(") || hql.contains("cube(") || hql.contains("grouping sets"))) {
hql = expandToUnionAll(hql);
} Type guard
static boolean groupingSetsSafe(Dialect d) {
return !(d instanceof org.hibernate.community.dialect.H2LegacyDialect);
} Try / catch
try {
rows = session.createQuery(hql).getResultList(); // rollup/cube/grouping sets
} catch (UnsupportedOperationException e) {
if (e.getMessage().contains("Summarization")) {
// re-run as union-all of plain group-by queries
} else throw e;
} Prevention
- Run grouping-set analytics on the non-legacy H2 dialect or the production database, not the legacy profile
- Wrap rollup/cube queries in per-dialect repository methods
- Compute totals/subtotals in Java when the detail set is already loaded
When it happens
Trigger: HQL with rollup/cube/grouping sets executed under the H2 legacy dialect, e.g. 'select d.name, count(e) from Employee e join e.dept d group by rollup(d.name)', particularly when surrounding query elements (window functions, tuple comparisons) force partition-item rendering.
Common situations: Reporting/subtotal queries written on newer databases but executed in H2-based legacy test suites; migrating an app to Hibernate 6/7 where the H2 test database stayed on the legacy dialect; analytics code sharing between production PostgreSQL and H2 staging.
Related errors
- Summarization is not supported by DBMS!
- Insert conflict 'do update' clause with constraint name is n
- Summarization is not supported by DBMS
- Summarization is not supported by DBMS
- Summarization is not supported by DBMS
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/8cdefda16fa7f4af.
Report an issue: GitHub.