hibernate/hibernate-orm · error · UnsupportedOperationException

Summarization is not supported by DBMS

Error message

Summarization is not supported by DBMS

What it means

PostgreSQLLegacySqlAstTranslator.renderPartitionItem() renders GROUP BY items that are Summarizations (rollup/cube/grouping sets). PostgreSQL only gained native grouping-sets syntax in 9.5, so for earlier versions the translator throws UnsupportedOperationException rather than attempting the (theoretically possible but inefficient) union-all emulation noted in the source comment.

Source

Thrown at hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/PostgreSQLLegacySqlAstTranslator.java:260

				appendSql( "()" );
			}
			else {
				appendSql( "(select 1)" );
			}
		}
		else if ( expression instanceof Summarization ) {
			Summarization summarization = (Summarization) expression;
			if ( getDialect().getVersion().isSameOrAfter( 9, 5 ) ) {
				appendSql( summarization.getKind().sqlText() );
				appendSql( OPEN_PARENTHESIS );
				renderCommaSeparated( summarization.getGroupings() );
				appendSql( CLOSE_PARENTHESIS );
			}
			else {
				// 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 visitLikePredicate(LikePredicate likePredicate) {
		// We need a custom implementation here because PostgreSQL
		// uses the backslash character as default escape character
		// According to the documentation, we can overcome this by specifying an empty escape character
		// See https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE
		likePredicate.getMatchExpression().accept( this );
		if ( likePredicate.isNegated() ) {
			appendSql( " not" );
		}
		if ( likePredicate.isCaseSensitive() ) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Upgrade PostgreSQL to 9.5 or newer
  2. If the server is already 9.5+, remove the pinned old dialect version or fix version detection
  3. Emulate rollup manually with union all of the grouped query variants
  4. Compute subtotal/total rows in the application layer

Example fix

-- before (HQL, on PG < 9.5)
select year(e.date), e.dept, sum(e.amount) from Expense e
 group by rollup(year(e.date), e.dept)

-- after: emulate with union all
select year(e.date), e.dept, sum(e.amount) from Expense e group by year(e.date), e.dept
union all
select year(e.date), null, sum(e.amount) from Expense e group by year(e.date)
union all
select null, null, sum(e.amount) from Expense e
Defensive patterns

Strategy: validation

Validate before calling

Dialect d = sessionFactory.getJdbcServices().getDialect();
boolean supportsGroupingSets = !( d instanceof PostgreSQLLegacyDialect pg )
        || pg.getVersion().isSameOrAfter( 9, 5 );
if ( !supportsGroupingSets ) {
    // run the union-all emulation instead of 'group by rollup'
}

Try / catch

try {
    return em.createQuery( rollupHql ).getResultList();
}
catch ( UnsupportedOperationException e ) {
    if ( e.getMessage() != null && e.getMessage().contains( "Summarization" ) ) {
        // pre-9.5 PostgreSQL: switch to the union-all emulation query
        return em.createQuery( unionAllHql ).getResultList();
    }
    throw e;
}

Prevention

When it happens

Trigger: HQL/Criteria with 'group by rollup(...)', 'cube(...)' or 'grouping sets(...)' executed against PostgreSQL 9.4 or older, or a PostgreSQLLegacyDialect whose version was explicitly pinned below 9.5.

Common situations: Legacy reporting databases still on old 9.x releases; dialect version pinned via an explicit constructor argument because JDBC metadata detection was disabled (hibernate.temp.use_jdbc_metadata_defaults=false).

Related errors


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