Package org.hibernate.query
Class Order<X>
- java.lang.Object
-
- org.hibernate.query.Order<X>
-
- Type Parameters:
X
- The result type of the query to be sorted
@Incubating public class Order<X> extends Object
A rule for sorting a query result set.This is a convenience class which allows query result ordering rules to be passed around the system before being applied to a
Query
by callingSelectionQuery.setOrder(java.util.List<org.hibernate.query.Order<? super R>>)
.A parameter of a finder method or HQL query method may be declared with type
Order<? super E>
,List<Order<? super E>>
, orOrder<? super E>...
(varargs) whereE
is the entity type returned by the query.- Since:
- 6.3
- See Also:
SelectionQuery.setOrder(Order)
,SelectionQuery.setOrder(java.util.List)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Order<Object[]>
asc(int element)
An order where the result set is sorted by the select item in the given position with smaller values first.static <T> Order<T>
asc(SingularAttribute<T,?> attribute)
An order where an entity is sorted by the given attribute, with smaller values first.static <T> Order<T>
asc(Class<T> entityClass, String attributeName)
An order where an entity of the given class is sorted by the attribute with the given name, with smaller values first.static Order<Object[]>
by(int element, SortDirection direction)
An order where the result set is sorted by the select item in the given position, in the given direction.static Order<Object[]>
by(int element, SortDirection direction, boolean ignoreCase)
An order where the result set is sorted by the select item in the given position in the given direction, with the specified case-sensitivity.static Order<Object[]>
by(int element, SortDirection direction, NullPrecedence nullPrecedence)
An order where the result set is sorted by the select item in the given position in the given direction, with the specified precedence for null values.static <T> Order<T>
by(SingularAttribute<T,?> attribute, SortDirection direction)
An order where an entity is sorted by the given attribute, in the given direction.static <T> Order<T>
by(SingularAttribute<T,?> attribute, SortDirection direction, boolean ignoreCase)
An order where an entity is sorted by the given attribute, in the given direction, with the specified case-sensitivity.static <T> Order<T>
by(SingularAttribute<T,?> attribute, SortDirection direction, NullPrecedence nullPrecedence)
An order where an entity is sorted by the given attribute, in the given direction, with the specified precedence for null values.static <T> Order<T>
by(Class<T> entityClass, String attributeName, SortDirection direction)
An order where an entity of the given class is sorted by the attribute with the given name, in the given direction.static <T> Order<T>
by(Class<T> entityClass, String attributeName, SortDirection direction, boolean ignoreCase)
An order where an entity of the given class is sorted by the attribute with the given name, in the given direction, with the specified case-sensitivity.static <T> Order<T>
by(Class<T> entityClass, String attributeName, SortDirection direction, NullPrecedence nullPrecedence)
An order where an entity of the given class is sorted by the attribute with the given name, in the given direction.static Order<Object[]>
desc(int element)
An order where the result set is sorted by the select item in the given position with larger values first.static <T> Order<T>
desc(SingularAttribute<T,?> attribute)
An order where an entity is sorted by the given attribute, with larger values first.static <T> Order<T>
desc(Class<T> entityClass, String attributeName)
An order where an entity of the given class is sorted by the attribute with the given name, with larger values first.boolean
equals(Object o)
SingularAttribute<X,?>
getAttribute()
String
getAttributeName()
SortDirection
getDirection()
int
getElement()
Class<X>
getEntityClass()
NullPrecedence
getNullPrecedence()
int
hashCode()
Order<X>
ignoringCase()
boolean
isCaseInsensitive()
Order<X>
reverse()
static <T> List<Order<? super T>>
reverse(List<Order<? super T>> ordering)
Reverse the direction of the given ordering listString
toString()
Order<X>
withNullsFirst()
Order<X>
withNullsLast()
-
-
-
Method Detail
-
asc
public static <T> Order<T> asc(SingularAttribute<T,?> attribute)
An order where an entity is sorted by the given attribute, with smaller values first. If the give attribute is of textual type, the ordering is case-sensitive.
-
desc
public static <T> Order<T> desc(SingularAttribute<T,?> attribute)
An order where an entity is sorted by the given attribute, with larger values first. If the give attribute is of textual type, the ordering is case-sensitive.
-
by
public static <T> Order<T> by(SingularAttribute<T,?> attribute, SortDirection direction)
An order where an entity is sorted by the given attribute, in the given direction. If the give attribute is of textual type, the ordering is case-sensitive.
-
by
public static <T> Order<T> by(SingularAttribute<T,?> attribute, SortDirection direction, boolean ignoreCase)
An order where an entity is sorted by the given attribute, in the given direction, with the specified case-sensitivity.
-
by
public static <T> Order<T> by(SingularAttribute<T,?> attribute, SortDirection direction, NullPrecedence nullPrecedence)
An order where an entity is sorted by the given attribute, in the given direction, with the specified precedence for null values. If the give attribute is of textual type, the ordering is case-sensitive.
-
asc
public static <T> Order<T> asc(Class<T> entityClass, String attributeName)
An order where an entity of the given class is sorted by the attribute with the given name, with smaller values first. If the named attribute is of textual type, the ordering is case-sensitive.
-
desc
public static <T> Order<T> desc(Class<T> entityClass, String attributeName)
An order where an entity of the given class is sorted by the attribute with the given name, with larger values first. If the named attribute is of textual type, the ordering is case-sensitive.
-
by
public static <T> Order<T> by(Class<T> entityClass, String attributeName, SortDirection direction)
An order where an entity of the given class is sorted by the attribute with the given name, in the given direction. If the named attribute is of textual type, the ordering is case-sensitive.
-
by
public static <T> Order<T> by(Class<T> entityClass, String attributeName, SortDirection direction, boolean ignoreCase)
An order where an entity of the given class is sorted by the attribute with the given name, in the given direction, with the specified case-sensitivity.
-
by
public static <T> Order<T> by(Class<T> entityClass, String attributeName, SortDirection direction, NullPrecedence nullPrecedence)
An order where an entity of the given class is sorted by the attribute with the given name, in the given direction. If the named attribute is of textual type, with the specified precedence for null values. If the named attribute is of textual type, the ordering is case-sensitive.
-
asc
public static Order<Object[]> asc(int element)
An order where the result set is sorted by the select item in the given position with smaller values first. If the item is of textual type, the ordering is case-sensitive.
-
desc
public static Order<Object[]> desc(int element)
An order where the result set is sorted by the select item in the given position with larger values first. If the item is of textual type, the ordering is case-sensitive.
-
by
public static Order<Object[]> by(int element, SortDirection direction)
An order where the result set is sorted by the select item in the given position, in the given direction. If the item is of textual type, the ordering is case-sensitive.
-
by
public static Order<Object[]> by(int element, SortDirection direction, boolean ignoreCase)
An order where the result set is sorted by the select item in the given position in the given direction, with the specified case-sensitivity.
-
by
public static Order<Object[]> by(int element, SortDirection direction, NullPrecedence nullPrecedence)
An order where the result set is sorted by the select item in the given position in the given direction, with the specified precedence for null values. If the named attribute is of textual type, the ordering is case-sensitive.
-
getDirection
public SortDirection getDirection()
-
getNullPrecedence
public NullPrecedence getNullPrecedence()
-
isCaseInsensitive
public boolean isCaseInsensitive()
-
getAttribute
public SingularAttribute<X,?> getAttribute()
-
getAttributeName
public String getAttributeName()
-
getElement
public int getElement()
-
reverse
public Order<X> reverse()
- Returns:
- this order, but with the sorting direction reversed.
- Since:
- 6.5
-
ignoringCase
public Order<X> ignoringCase()
- Returns:
- this order, but without case-sensitivity.
- Since:
- 6.5
-
withNullsFirst
public Order<X> withNullsFirst()
- Returns:
- this order, but with nulls sorted first.
- Since:
- 6.5
-
withNullsLast
public Order<X> withNullsLast()
- Returns:
- this order, but with nulls sorted last.
- Since:
- 6.5
-
-