Class JpaSort
java.lang.Object
org.springframework.data.domain.Sort
org.springframework.data.jpa.domain.JpaSort
- All Implemented Interfaces:
Serializable, Iterable<Sort.Order>, Supplier<Stream<Sort.Order>>, Streamable<Sort.Order>
Sort option for queries that wraps JPA metamodel
Attributes for sorting.
unsafe(String...) accepts unsafe sort expressions, i. e. the String provided is not necessarily a property but
can be an arbitrary expression piped into the query execution.
- Author:
- Thomas Darimont, Oliver Gierke, Christoph Strobl, David Madden, Jens Schauder, Ngoc Nhan
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCustomSort.Orderthat keeps a flag to indicate unsafe property handling, i.e. the String provided is not necessarily a property but can be an arbitrary expression piped into the query execution.static classValue object to abstract a collection ofAttributes.Nested classes/interfaces inherited from class Sort
Sort.Direction, Sort.NullHandling, Sort.Order, Sort.TypedSort<T> -
Field Summary
Fields inherited from class Sort
DEFAULT_DIRECTION -
Method Summary
Modifier and TypeMethodDescriptionand(@Nullable Sort.Direction direction, jakarta.persistence.metamodel.Attribute<?, ?>... attributes) Returns a newJpaSortwith the given sorting criteria added to the current one.and(@Nullable Sort.Direction direction, JpaSort.Path<?, ?>... paths) Returns a newJpaSortwith the given sorting criteria added to the current one.andUnsafe(@Nullable Sort.Direction direction, String... properties) Returns a newJpaSortwith the given sorting criteria added to the current one.static JpaSortof(jakarta.persistence.metamodel.Attribute<?, ?>... attributes) Creates a newJpaSortfor the given attributes with the default sort direction.static JpaSortof(Sort.Direction direction, jakarta.persistence.metamodel.Attribute<?, ?>... attributes) Creates a newJpaSortfor the given direction and attributes.static JpaSortof(Sort.Direction direction, JpaSort.Path<?, ?>... paths) Creates a newJpaSortfor the given direction andJpaSort.Paths.static JpaSortof(JpaSort.Path<?, ?>... paths) Creates a newJpaSortinstance with the givenJpaSort.Paths.static <A extends jakarta.persistence.metamodel.Attribute<T,S>, T, S>
JpaSort.Path<T, S> path(A attribute) Creates a newJpaSort.Pathfor the givenAttribute.static <P extends jakarta.persistence.metamodel.PluralAttribute<T,?, S>, T, S>
JpaSort.Path<T, S> path(P attribute) Creates a newJpaSort.Pathfor the givenPluralAttribute.static JpaSortCreates new unsafeJpaSortbased on given properties.static JpaSortunsafe(Sort.Direction direction, String... properties) Creates new unsafeJpaSortbased on givenSort.Directionand properties.static JpaSortunsafe(Sort.Direction direction, List<String> properties) Creates new unsafeJpaSortbased on givenSort.Directionand properties.Methods inherited from class Sort
and, ascending, by, by, by, by, descending, doReverse, equals, getOrderFor, hashCode, isEmpty, isSorted, isUnsorted, iterator, reverse, sort, toString, unsortedMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
of
-
of
Creates a newJpaSortinstance with the givenJpaSort.Paths.- Parameters:
paths- must not be null or empty.
-
of
public static JpaSort of(Sort.Direction direction, jakarta.persistence.metamodel.Attribute<?, ?>... attributes) Creates a newJpaSortfor the given direction and attributes.- Parameters:
direction- the sorting direction.attributes- must not be null or empty.
-
of
Creates a newJpaSortfor the given direction andJpaSort.Paths.- Parameters:
direction- the sorting direction.paths- must not be null or empty.
-
and
@Contract("_, _ -> new") @CheckReturnValue public JpaSort and(@Nullable Sort.Direction direction, jakarta.persistence.metamodel.Attribute<?, ?>... attributes) Returns a newJpaSortwith the given sorting criteria added to the current one.- Parameters:
direction- can be null.attributes- must not be null.- Returns:
-
and
@Contract("_, _ -> new") @CheckReturnValue public JpaSort and(@Nullable Sort.Direction direction, JpaSort.Path<?, ?>... paths) Returns a newJpaSortwith the given sorting criteria added to the current one.- Parameters:
direction- can be null.paths- must not be null.- Returns:
-
andUnsafe
@Contract("_, _ -> new") @CheckReturnValue public JpaSort andUnsafe(@Nullable Sort.Direction direction, String... properties) Returns a newJpaSortwith the given sorting criteria added to the current one.- Parameters:
direction- can be null.properties- must not be null or empty.- Returns:
-
path
public static <A extends jakarta.persistence.metamodel.Attribute<T,S>, T, S> JpaSort.Path<T,S> path(A attribute) Creates a newJpaSort.Pathfor the givenAttribute.- Parameters:
attribute- must not be null.- Returns:
-
path
public static <P extends jakarta.persistence.metamodel.PluralAttribute<T,?, JpaSort.Path<T,S>, T, S> S> path(P attribute) Creates a newJpaSort.Pathfor the givenPluralAttribute.- Parameters:
attribute- must not be null.- Returns:
-
unsafe
-
unsafe
Creates new unsafeJpaSortbased on givenSort.Directionand properties.- Parameters:
direction- must not be null.properties- must not be null or empty.- Returns:
-
unsafe
Creates new unsafeJpaSortbased on givenSort.Directionand properties.- Parameters:
direction- must not be null.properties- must not be null or empty.- Returns:
-