hibernate/hibernate-orm · error · IllegalArgumentException
empty selections passed to criteria query typed as Object
Error message
empty selections passed to criteria query typed as Object
What it means
Error "empty selections passed to criteria query typed as Object" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/select/SqmSelectStatement.java:380
@Nonnull
@Override @Deprecated
public SqmSelectStatement<T> multiselect(@Nonnull List<Selection<?>> selectionList) {
if ( nodeBuilder().isJpaQueryComplianceEnabled() ) {
for ( Selection<?> selection : selectionList ) {
checkSelectionIsJpaCompliant( selection );
}
}
getQuerySpec().getSelectClause()
.setSelection( (SqmSelectableNode<?>) getResultSelection( selectionList ) );
return this;
}
private JpaSelection<?> getResultSelection(List<Selection<?>> selections) {
final Class<T> resultType = getResultType();
if ( resultType == Object.class ) {
return switch ( selections.size() ) {
case 0 -> throw new IllegalArgumentException(
"empty selections passed to criteria query typed as Object" );
case 1 -> (JpaSelection<?>) selections.get( 0 );
default -> nodeBuilder().array( selections );
};
}
else if ( Tuple.class.isAssignableFrom( resultType ) ) {
return nodeBuilder().tuple( selections );
}
else if ( resultType.isArray() ) {
return nodeBuilder().array( resultType, selections );
}
else {
return nodeBuilder().construct( resultType, selections );
}
}
private void checkSelectionIsJpaCompliant(Selection<?> selection) {
if ( selection instanceof SqmSubQuery<?> ) {View on GitHub (pinned to fad1729dce)
Solutions
- Provide at least one selection to the criteria query (e.g. select(root) or multiselect(...)).
- If a compound result is intended, type the query as Tuple/Object[] and supply multiple selections.
- Guard dynamic selection-list building so an empty list is never passed.
When it happens
Trigger: A select statement typed as Object is given an empty selection list.
Common situations: Empty multiselect on an Object-typed query; supply selections or use Object[].class.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/9fe585c8ab49490d.
Report an issue: GitHub.