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 meta-model
Attribute
s for sorting.- Author:
- Thomas Darimont, Oliver Gierke, Christoph Strobl, David Madden, Jens Schauder
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
CustomSort.Order
that 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 class
Value object to abstract a collection ofAttribute
s.Nested classes/interfaces inherited from class org.springframework.data.domain.Sort
Sort.Direction, Sort.NullHandling, Sort.Order, Sort.TypedSort<T extends Object>
-
Field Summary
Fields inherited from class org.springframework.data.domain.Sort
DEFAULT_DIRECTION
-
Method Summary
Modifier and TypeMethodDescriptionand
(Sort.Direction direction, jakarta.persistence.metamodel.Attribute<?, ?>... attributes) Returns a newJpaSort
with the given sorting criteria added to the current one.and
(Sort.Direction direction, JpaSort.Path<?, ?>... paths) Returns a newJpaSort
with the given sorting criteria added to the current one.andUnsafe
(Sort.Direction direction, String... properties) Returns a newJpaSort
with the given sorting criteria added to the current one.static JpaSort
of
(jakarta.persistence.metamodel.Attribute<?, ?>... attributes) Creates a newJpaSort
for the given attributes with the default sort direction.static JpaSort
of
(Sort.Direction direction, jakarta.persistence.metamodel.Attribute<?, ?>... attributes) Creates a newJpaSort
for the given direction and attributes.static JpaSort
of
(Sort.Direction direction, JpaSort.Path<?, ?>... paths) Creates a newJpaSort
for the given direction andJpaSort.Path
s.static JpaSort
of
(JpaSort.Path<?, ?>... paths) Creates a newJpaSort
instance with the givenJpaSort.Path
s.static <A extends jakarta.persistence.metamodel.Attribute<T,
S>, T, S>
JpaSort.Path<T,S> path
(A attribute) Creates a newJpaSort.Path
for the givenAttribute
.static <P extends jakarta.persistence.metamodel.PluralAttribute<T,
?, S>, T, S>
JpaSort.Path<T,S> path
(P attribute) Creates a newJpaSort.Path
for the givenPluralAttribute
.static JpaSort
Creates new unsafeJpaSort
based on given properties.static JpaSort
unsafe
(Sort.Direction direction, String... properties) Creates new unsafeJpaSort
based on givenSort.Direction
and properties.static JpaSort
unsafe
(Sort.Direction direction, List<String> properties) Creates new unsafeJpaSort
based on givenSort.Direction
and properties.Methods inherited from class org.springframework.data.domain.Sort
and, ascending, by, by, by, by, descending, doReverse, equals, getOrderFor, hashCode, isEmpty, isSorted, isUnsorted, iterator, reverse, sort, toString, unsorted
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
of
Creates a newJpaSort
for the given attributes with the default sort direction.- Parameters:
attributes
- must not be null or empty.
-
of
Creates a newJpaSort
instance with the givenJpaSort.Path
s.- Parameters:
paths
- must not be null or empty.
-
of
public static JpaSort of(Sort.Direction direction, jakarta.persistence.metamodel.Attribute<?, ?>... attributes) Creates a newJpaSort
for the given direction and attributes.- Parameters:
direction
- the sorting direction.attributes
- must not be null or empty.
-
of
Creates a newJpaSort
for the given direction andJpaSort.Path
s.- Parameters:
direction
- the sorting direction.paths
- must not be null or empty.
-
and
public JpaSort and(@Nullable Sort.Direction direction, jakarta.persistence.metamodel.Attribute<?, ?>... attributes) Returns a newJpaSort
with the given sorting criteria added to the current one.- Parameters:
direction
- can be null.attributes
- must not be null.- Returns:
-
and
Returns a newJpaSort
with the given sorting criteria added to the current one.- Parameters:
direction
- can be null.paths
- must not be null.- Returns:
-
andUnsafe
Returns a newJpaSort
with 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>, JpaSort.Path<T,T, S> S> path(A attribute) Creates a newJpaSort.Path
for 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.Path
for the givenPluralAttribute
.- Parameters:
attribute
- must not be null.- Returns:
-
unsafe
Creates new unsafeJpaSort
based on given properties.- Parameters:
properties
- must not be null or empty.- Returns:
-
unsafe
Creates new unsafeJpaSort
based on givenSort.Direction
and properties.- Parameters:
direction
- must not be null.properties
- must not be null or empty.- Returns:
-
unsafe
Creates new unsafeJpaSort
based on givenSort.Direction
and properties.- Parameters:
direction
- must not be null.properties
- must not be null or empty.- Returns:
-