hibernate/hibernate-orm · error · UnsupportedOperationException

Summarization is not supported by DBMS

Error message

Summarization is not supported by DBMS

What it means

SybaseSqlAstTranslator.renderPartitionItem throws UnsupportedOperationException('Summarization is not supported by DBMS') when a Summarization expression (rollup/cube/grouping sets from HQL GROUP BY or window PARTITION BY) must be rendered for the SQL Anywhere dialect. Per the in-code comment, emulating it would require rendering all grouping variations of the query and connecting them with union all at the query-spec level, which is not implemented; the literal branch just above (dummy_.x) shows the kind of emulation applied to other special items instead.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/sql/ast/SybaseSqlAstTranslator.java:287

	@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 ) {
			// Note that this depends on the SqmToSqlAstConverter to add a dummy table group
			appendSql( "dummy_.x" );
		}
		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 boolean needsRowsToSkip() {
		return true;

View on GitHub (pinned to fad1729dce)

Solutions

  1. Split into one GROUP BY query per grouping level and merge in application code
  2. Compute totals separately and combine client-side
  3. Run grouping-sets reports on a database that supports them
  4. Hand-write the UNION ALL expansion in native SQL if it must run on SQL Anywhere

Example fix

// before (throws on SQL Anywhere)
"select region, sum(amount) from Donation d group by rollup (d.region)"

// after
byRegion = em.createQuery("select region, sum(amount) ... group by region");
total = em.createQuery("select sum(amount) from Donation d");
Defensive patterns

Strategy: validation

Validate before calling

static boolean supportsSummarization(Dialect dialect) {
    return !(dialect instanceof SQLAnywhereDialect || dialect instanceof SybaseASEDialect
        || dialect instanceof HSQLDialect || dialect instanceof SpannerDialect);
}

if (usesGroupingSets(hql) && !supportsSummarization(dialect)) {
    return expandedGrouping(query);
}

Try / catch

try {
    return em.createQuery(cubeHql, Object[].class).getResultList();
} catch (UnsupportedOperationException e) {
    if ("Summarization is not supported by DBMS".equals(e.getMessage())) {
        return expandedGrouping(query);
    }
    throw e;
}

Prevention

When it happens

Trigger: HQL 'group by rollup(...)' / 'cube(...)' / 'grouping sets(...)' or an OVER(PARTITION BY rollup(...)) item executed with SQLAnywhereDialect; fails at SQL rendering time.

Common situations: Running report HQL originally written for SQL Server/PostgreSQL against SQL Anywhere; cross-dialect test suites including grouping-sets queries.

Related errors


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