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 syntax - 'group by rollup(...)', 'cube(...)', 'grouping sets(...)' - produces a Summarization AST node. FirebirdSqlAstTranslator.renderPartitionItem must render grouping expressions when Hibernate emulates aggregation/window constructs; for a Summarization it throws UnsupportedOperationException because Firebird cannot emulate the grouping variations (the comment notes the only theoretical emulation is a union of per-variation queries, which is not implemented).

Source

Thrown at hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/FirebirdSqlAstTranslator.java:235

	@Override
	protected void renderSelectTupleComparison(
			List<SqlSelection> lhsExpressions,
			SqlTuple tuple,
			ComparisonOperator operator) {
		emulateSelectTupleComparison( lhsExpressions, tuple.getExpressions(), operator, true );
	}

	@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 visitInListPredicate(InListPredicate inListPredicate) {
		final List<Expression> listExpressions = inListPredicate.getListExpressions();
		if ( listExpressions.isEmpty() ) {
			appendSql( "1=" + ( inListPredicate.isNegated() ? "1" : "0" ) );
			return;
		}
		final Expression testExpression = inListPredicate.getTestExpression();
		if ( isParameter( testExpression ) ) {
			renderCasted( testExpression );
			if ( inListPredicate.isNegated() ) {
				appendSql( " not" );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Replace the single rollup/cube query with an explicit GROUPING SETS emulation: run one plain group-by query per grouping variation and merge with UNION ALL in Java or native SQL
  2. Precompute the subtotals into a summary table (via ETL or a scheduled job) and query that table on Firebird
  3. If the analytics database can differ from the OLTP one, run rollup/cube reports on a database whose dialect supports Summarization
  4. Drop the rollup and compute totals in the presentation layer from the detail rows

Example fix

// before (HQL, throws on Firebird)
select p.kind, p.breed, count(*) from Pet p group by rollup(p.kind, p.breed)

// after (union of variations, native or HQL union)
select kind, breed, count(*) c from Pet group by kind, breed
union all
select kind, null, count(*) c from Pet group by kind
union all
select null, null, count(*) c from Pet
Defensive patterns

Strategy: validation

Validate before calling

Dialect d = sessionFactory.getJdbcServices().getDialect();
if (d instanceof FirebirdDialect && (hql.contains("rollup(") || hql.contains("cube(") || hql.contains("grouping sets"))) {
    hql = expandGroupingSetsToUnionAll(hql); // one plain group-by per variation
}

Type guard

static boolean groupingSetsSafe(Dialect d) {
    return !(d instanceof FirebirdDialect);
}

Try / catch

try {
    rows = session.createQuery(hql).getResultList(); // hql uses rollup/cube
} catch (UnsupportedOperationException e) {
    if (e.getMessage().contains("Summarization")) {
        // re-run as union-all of plain group-by variations
    } else throw e;
}

Prevention

When it happens

Trigger: An HQL query using rollup/cube/grouping sets against Firebird, e.g. 'select cat, count(*) from Pet p group by rollup(p.kind, p.breed)', especially when the surrounding query forces partition-item rendering (window-function emulation, tuple comparisons, distinct/aggregate wrapping).

Common situations: OLAP-style subtotal queries written for PostgreSQL/Oracle being reused on Firebird; reporting modules that assume SQL:1999 grouping sets everywhere; test suites with a Firebird member failing only on aggregation-heavy cases.

Related errors


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