hibernate/hibernate-orm · error · UnsupportedOperationException

Summarization is not supported by DBMS

Error message

Summarization is not supported by DBMS

What it means

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.

Source

Thrown at hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/HSQLLegacySqlAstTranslator.java:309

					render( rhs, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );
				}
				break;
			default:
				renderComparisonStandard( lhs, operator, rhs );
				break;
		}
	}

	@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 );
		}
	}

	private boolean supportsOffsetFetchClause() {
		return getDialect().getVersion().isSameOrAfter( 2, 5 );
	}

	@Override
	protected void visitArithmeticOperand(Expression expression) {
		render( expression, SqlAstNodeRenderingMode.NO_PLAIN_PARAMETER );
	}
}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Rewrite the aggregation as explicit per-level queries combined with UNION ALL
  2. Compute the grouping sets in Java: fetch the detailed rows and aggregate with streams, or run separate grouped queries
  3. Use a native query for the HSQLDB test profile, or switch tests to a database whose dialect supports summarization

Example fix

// before
"select dept, count(e) from Employee e group by rollup(e.dept)"

// after
"select e.dept, count(e) from Employee e group by e.dept" +
" union all " +
"select null, count(e) from Employee e"
Defensive patterns

Strategy: try-catch

Validate before calling

static boolean dialectSupportsSummarization(Dialect d) {
    return !(d instanceof HSQLLegacyDialect);
}
if ( !dialectSupportsSummarization(session.getJdbcServices().getDialect())
        && hql.toLowerCase().matches("(?s).*(rollup|grouping\\s+sets)\\s*\\(.*") ) {
    // rewrite or skip
}

Type guard

static boolean isLegacyHsqldb(Dialect d) { return d instanceof HSQLLegacyDialect; }

Try / catch

try {
    return em.createQuery(hql, Object[].class).getResultList();
} catch (UnsupportedOperationException e) {
    if ( String.valueOf(e.getMessage()).contains("Summarization") ) {
        return runGroupingSetsFallback(hql); // union-all or in-memory aggregation
    }
    throw e;
}

Prevention

When it happens

Trigger: Executing HQL/criteria with 'group by rollup(...)' or 'group by grouping sets(...)' on HSQLLegacyDialect; renderPartitionItem() receives the Summarization node during SQL generation and throws.

Common situations: 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.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/fc4e7d1a2ab20415. Report an issue: GitHub.