Search in sources :

Example 11 with SqmSortSpecification

use of org.hibernate.query.sqm.tree.select.SqmSortSpecification in project hibernate-orm by hibernate.

the class FromClauseTests method testFromElementReferenceInOrderBy.

@Test
public void testFromElementReferenceInOrderBy() {
    final String query = "select p from Person p order by p";
    SqmSelectStatement<?> selectStatement = interpretSelect(query);
    final SqmFromClause fromClause = selectStatement.getQuerySpec().getFromClause();
    assertThat(fromClause, notNullValue());
    assertThat(fromClause.getRoots(), hasSize(1));
    final List<SqmSortSpecification> orderBy = selectStatement.getQuerySpec().getOrderByClause().getSortSpecifications();
    assertThat(orderBy, hasSize(1));
    assertThat(orderBy.get(0).getSortExpression(), instanceOf(SqmRoot.class));
}
Also used : SqmFromClause(org.hibernate.query.sqm.tree.from.SqmFromClause) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SqmSortSpecification(org.hibernate.query.sqm.tree.select.SqmSortSpecification) SqmRoot(org.hibernate.query.sqm.tree.from.SqmRoot) BaseSqmUnitTest(org.hibernate.orm.test.query.sqm.BaseSqmUnitTest) Test(org.junit.jupiter.api.Test)

Aggregations

SqmSortSpecification (org.hibernate.query.sqm.tree.select.SqmSortSpecification)11 SortSpecification (org.hibernate.sql.ast.tree.select.SortSpecification)5 SelfRenderingFunctionSqlAstExpression (org.hibernate.query.sqm.function.SelfRenderingFunctionSqlAstExpression)3 ArgumentsValidator (org.hibernate.query.sqm.produce.function.ArgumentsValidator)3 SqmExpression (org.hibernate.query.sqm.tree.expression.SqmExpression)3 SqlAstNode (org.hibernate.sql.ast.tree.SqlAstNode)3 Over (org.hibernate.sql.ast.tree.expression.Over)3 ArrayList (java.util.ArrayList)2 ParseTree (org.antlr.v4.runtime.tree.ParseTree)2 HqlParser (org.hibernate.grammars.hql.HqlParser)2 SelfRenderingOrderedSetAggregateFunctionSqlAstExpression (org.hibernate.query.sqm.function.SelfRenderingOrderedSetAggregateFunctionSqlAstExpression)2 SqmToSqlAstConverter (org.hibernate.query.sqm.sql.SqmToSqlAstConverter)2 SqmOver (org.hibernate.query.sqm.tree.expression.SqmOver)2 SqmPredicate (org.hibernate.query.sqm.tree.predicate.SqmPredicate)2 SqmOrderByClause (org.hibernate.query.sqm.tree.select.SqmOrderByClause)2 Clause (org.hibernate.sql.ast.Clause)2 Predicate (org.hibernate.sql.ast.tree.predicate.Predicate)2 Test (org.junit.Test)2 Order (jakarta.persistence.criteria.Order)1 BigInteger (java.math.BigInteger)1