Skip to content

Commit

Permalink
improve error when a select item is missing its required alias
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed May 28, 2023
1 parent 23b55db commit a6f036d
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.metamodel.model.domain.TupleType;
import org.hibernate.query.ReturnableType;
import org.hibernate.query.SemanticException;
import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.tree.domain.SqmPath;
Expand Down Expand Up @@ -58,7 +59,8 @@ public AnonymousTupleType(SqmSelectableNode<?>[] components) {
final SqmSelectableNode<?> component = components[i];
final String alias = component.getAlias();
if ( alias == null ) {
throw new IllegalArgumentException( "Component at index " + i + " has no alias, but alias is required" );
throw new SemanticException( "Select item at position " + (i+1) + " in select list has no alias"
+ " (aliases are required in CTEs and in subqueries occurring in from clause)" );
}
map.put( alias, i );
}
Expand Down

0 comments on commit a6f036d

Please sign in to comment.