hibernate/hibernate-orm · error · IllegalArgumentException

Unsupported aggregate SQL type: {}

Error message

Unsupported aggregate SQL type: {}

What it means

Error "Unsupported aggregate SQL type: {}" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/aggregate/PostgreSQLAggregateSupport.java:165

						// We encode binary data as hex, so we have to decode here
						return template.replace(
								placeholder,
								"decode((select t.v from xmltable(" + xmlExtractArguments( aggregateParentReadExpression, columnExpression )+ " columns v text path '.') t),'hex')"
						);
					case ARRAY:
						throw new UnsupportedOperationException( "Transforming XML_ARRAY to native arrays is not supported on PostgreSQL!" );
					default:
						return template.replace(
								placeholder,
								"(select t.v from xmltable(" + xmlExtractArguments( aggregateParentReadExpression, columnExpression ) + " columns v " + getCastTypeName( column, typeConfiguration ) + " path '.') t)"
						);
				}
			case STRUCT:
			case STRUCT_ARRAY:
			case STRUCT_TABLE:
				return template.replace( placeholder, '(' + aggregateParentReadExpression + ")." + columnExpression );
		}
		throw new IllegalArgumentException( "Unsupported aggregate SQL type: " + aggregateColumnTypeCode );
	}

	private static String xmlExtractArguments(String aggregateParentReadExpression, String xpathFragment) {
		final String extractArguments;
		int separatorIndex;
		if ( aggregateParentReadExpression.startsWith( XML_EXTRACT_START )
			&& aggregateParentReadExpression.endsWith( XML_EXTRACT_END )
			&& (separatorIndex = aggregateParentReadExpression.indexOf( XML_EXTRACT_SEPARATOR )) != -1 ) {
			final var sb = new StringBuilder( aggregateParentReadExpression.length() - XML_EXTRACT_START.length() + xpathFragment.length() );
			sb.append( aggregateParentReadExpression, XML_EXTRACT_START.length(), separatorIndex );
			sb.append( '/' );
			sb.append( xpathFragment );
			sb.append( aggregateParentReadExpression, separatorIndex + 2, aggregateParentReadExpression.length() - XML_EXTRACT_END.length() );
			extractArguments = sb.toString();
		}
		else if ( aggregateParentReadExpression.startsWith( XML_QUERY_START )
				&& aggregateParentReadExpression.endsWith( XML_QUERY_END )
				&& (separatorIndex = aggregateParentReadExpression.indexOf( XML_QUERY_SEPARATOR )) != -1 ) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Map the aggregate column with a supported SQL type (JSON/ARRAY).
  2. Avoid the unsupported aggregate type on PostgreSQL.

When it happens

Trigger: Triggered when the application calls a Hibernate dialect feature that the configured database dialect cannot provide: Unsupported aggregate SQL type (PostgreSQL).

Common situations: Common when running against a database whose dialect lacks this capability, when a mapping or HQL/Criteria query requests unsupported functionality, or when the wrong dialect is configured for the database in use. Error: Unsupported aggregate SQL type (PostgreSQL).


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