hibernate/hibernate-orm · error · UnsupportedOperationException
Full join emulation requires order by expressions to be in t
Error message
Full join emulation requires order by expressions to be in the select list for union queries
What it means
Error "Full join emulation requires order by expressions to be in the select list for union queries" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/sql/ast/spi/FullJoinEmulation.java:539
translator.appendSql( separator );
renderFullJoinEmulationSortExpression(
sortSpecification,
sortSelectionIndexes[i],
nullPrecedenceSelectionIndexes == null ? -1 : nullPrecedenceSelectionIndexes[i]
);
separator = COMMA_SEPARATOR;
}
}
private void renderFullJoinEmulationSortExpression(
SortSpecification sortSpecification,
int sortSelectionIndex,
int nullPrecedenceSelectionIndex) {
if ( sortSpecification.isIgnoreCase() ) {
throw new UnsupportedOperationException( "Full join emulation does not support ignore case ordering for union queries" );
}
if ( sortSelectionIndex < 0 ) {
throw new UnsupportedOperationException( "Full join emulation requires order by expressions to be in the select list for union queries" );
}
final var sortOrder = sortSpecification.getSortOrder();
final var nullPrecedence = resolveRenderedNullPrecedence( sortSpecification );
final boolean renderNullPrecedence = nullPrecedence != null;
final boolean supportsNullPrecedence = renderNullPrecedence && translator.getDialect().supportsNullPrecedence();
if ( renderNullPrecedence && !supportsNullPrecedence ) {
if ( nullPrecedenceSelectionIndex < 0 ) {
throw new IllegalStateException( "Full join emulation null precedence index is missing for union query ordering" );
}
translator.appendSql( nullPrecedenceSelectionIndex + 1 );
translator.appendSql( COMMA_SEPARATOR );
}
translator.appendSql( sortSelectionIndex + 1 );
if ( sortOrder == SortDirection.DESCENDING ) {
translator.appendSql( " desc" );View on GitHub (pinned to fad1729dce)
Solutions
- Add every ORDER BY expression to the select list of each union query part.
- Alternatively order by select-item position or alias instead of by raw expression.
- Remove ORDER BY items that cannot be added to the select list.
When it happens
Trigger: Full join emulation on a union query requires every ORDER BY expression to appear in the select list, and one is missing.
Common situations: Ordering a UNION by a column not selected; add the order expression to the select list.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/dc92c6c344b3ce19.
Report an issue: GitHub.