hibernate/hibernate-orm · error · UnsupportedOperationException

Summarization is not supported by DBMS

Error message

Summarization is not supported by DBMS

What it means

HQL supports SQL:2011 summarization -- rollup(...), cube(...) and grouping sets (...) -- as GROUP BY / partition expressions (a Summarization AST node). HSQLDB cannot express these, and the only theoretical emulation (rendering every grouping variation and chaining them with union all, per the code comment) is not implemented, so HSQLSqlAstTranslator.renderPartitionItem throws UnsupportedOperationException('Summarization is not supported by DBMS') during SQL rendering. renderPartitionItem is the shared renderer for GROUP BY items and window-function PARTITION BY items (AbstractSqlAstTranslator.visitPartitionExpressions), so the throw fires for either shape.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/HSQLSqlAstTranslator.java:326

				}
				break;
			default:
				// HSQL has a broken 'is distinct from' operator
				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 true;
	}

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

}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Expand the summarization manually: run one plain GROUP BY query per grouping level and combine the results with union all / in-memory merging
  2. Compute subtotals/grand totals in separate queries and assemble them in Java rather than in SQL
  3. Run the report against a database that natively supports grouping sets (PostgreSQL, Oracle, DB2, SQL Server) instead of HSQLDB
  4. Fall back to a native SQL query only if HSQLDB stays the target (it still lacks grouping sets, so this means manual UNION ALL SQL)

Example fix

// before (throws on HSQLDB)
List<Object[]> rows = em.createQuery(
    "select d.name, count(e.id) from Employee e join e.dept d group by rollup(d.name)",
    Object[].class).getResultList();

// after: one query per grouping level, merged in memory
detail = em.createQuery("select d.name, count(e.id) ... group by d.name", ...).getResultList();
total  = em.createQuery("select count(e.id) from Employee e", ...).getResultList();
Defensive patterns

Strategy: validation

Validate before calling

// Block summarization queries on dialects whose translators reject them
static boolean supportsSummarization(Dialect dialect) {
    return !(dialect instanceof HSQLDialect
        || dialect instanceof SybaseASEDialect
        || dialect instanceof SQLAnywhereDialect
        || dialect instanceof SpannerDialect
        || dialect instanceof SpannerPostgreSQLDialect);
}

if (!supportsSummarization(dialect)) {
    return reportService.groupingExpanded(querySpec); // one query per level
}

Try / catch

try {
    return em.createQuery(rollupHql, Object[].class).getResultList();
} catch (UnsupportedOperationException e) {
    if ("Summarization is not supported by DBMS".equals(e.getMessage())) {
        return reportService.groupingExpanded(...); // fallback: per-level queries
    }
    throw e;
}

Prevention

When it happens

Trigger: Executing HQL containing 'group by rollup(e.dept, e.title)', 'group by cube(...)', 'group by grouping sets (...)', or a window function whose OVER(PARTITION BY ...) item is a Summarization, with HSQLDialect as the configured dialect. Also triggered by criteria/HQL aggregate reports that the SQM-to-SQL converter turns into Summarization nodes.

Common situations: Reporting queries developed against PostgreSQL/Oracle/DB2 and then executed in HSQLDB-based unit or integration tests; porting a BI-style grouped report to an HSQLDB environment; upgrading Hibernate and hitting previously-unparsed HQL that now parses into Summarization.

Related errors


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