HHH-16815 rename getSortOrder() -> getSortDirection()

This commit is contained in:
Gavin King 2023-07-05 13:09:51 +02:00
parent f2d6373409
commit 7227831d56
4 changed files with 17 additions and 6 deletions

View File

@ -15,7 +15,11 @@ import org.hibernate.query.SortDirection;
* @author Steve Ebersole
*/
public interface JpaOrder extends Order, JpaCriteriaNode {
SortDirection getSortOrder();
/**
* The direction, ascending or descending, in which to sort
*/
SortDirection getSortDirection();
/**
* Set the precedence of nulls for this order element
@ -31,9 +35,15 @@ public interface JpaOrder extends Order, JpaCriteriaNode {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Covariant returns
/**
* Reverse the sorting direction
*/
@Override
JpaOrder reverse();
/**
* The expression to sort by
*/
@Override
JpaExpression<?> getExpression();
}

View File

@ -2518,7 +2518,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
}
return new SortSpecification(
expression,
sortSpecification.getSortOrder(),
sortSpecification.getSortDirection(),
sortSpecification.getNullPrecedence()
);
}

View File

@ -48,11 +48,12 @@ public class SqmSortSpecification implements JpaOrder {
return new SqmSortSpecification( sortExpression.copy( context ), sortOrder, nullPrecedence );
}
public SqmExpression getSortExpression() {
public SqmExpression<?> getSortExpression() {
return sortExpression;
}
public SortDirection getSortOrder() {
@Override
public SortDirection getSortDirection() {
return sortOrder;
}

View File

@ -33,12 +33,12 @@ public class SortSpecificationReversalTests {
SqmSortSpecification order = new SqmSortSpecification( sortExpression, ASCENDING, FIRST );
assertEquals( sortExpression, order.getSortExpression() );
assertEquals( ASCENDING, order.getSortOrder() );
assertEquals( ASCENDING, order.getSortDirection() );
assertEquals( FIRST, order.getNullPrecedence() );
JpaOrder reversed = order.reverse();
assertEquals( DESCENDING, reversed.getSortOrder() );
assertEquals( DESCENDING, reversed.getSortDirection() );
assertEquals( FIRST, reversed.getNullPrecedence() );
assertNotSame( "Order.reverse() should create new instance", order, reversed );