Class SqlSort
java.lang.Object
org.springframework.data.domain.Sort
org.springframework.data.relational.domain.SqlSort
- All Implemented Interfaces:
Serializable
,Iterable<Sort.Order>
,Supplier<Stream<Sort.Order>>
,Streamable<Sort.Order>
SqlSort supports additional to
Sort
unsafe sort expressions. Such sort expressions get included in
a query as they are. The user has to ensure that they come from trusted sorted or are properly sanatized to prevent
SQL injection attacks.- Since:
- 3.1
- Author:
- Jens Schauder
- See Also:
-
Nested Class Summary
Modifier 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.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, String... paths) Returns a newSqlSort
with the given sorting criteria added to the current one.andUnsafe
(Sort.Direction direction, String... properties) Returns a newSqlSort
with the given sorting criteria added to the current one.static SqlSort
static SqlSort
of
(Sort.Direction direction, String... paths) static SqlSort
Creates new unsafeSqlSort
based on given properties.static SqlSort
unsafe
(Sort.Direction direction, String... properties) Creates new unsafeSqlSort
based on givenSort.Direction
and properties.static SqlSort
unsafe
(Sort.Direction direction, List<String> properties) Creates new unsafeSqlSort
based on givenSort.Direction
and properties.static void
validate
(Sort.Order order) Validates aSort.Order
, to be either safe for use in SQL or to be explicitely marked unsafe.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
- Parameters:
paths
- must not be null or empty.
-
of
- Parameters:
direction
- the sorting direction.paths
- must not be null or empty.
-
validate
Validates aSort.Order
, to be either safe for use in SQL or to be explicitely marked unsafe.- Parameters:
order
- theSort.Order
to validate. Must not be null.
-
unsafe
Creates new unsafeSqlSort
based on given properties.- Parameters:
properties
- must not be null or empty.- Returns:
-
unsafe
Creates new unsafeSqlSort
based on givenSort.Direction
and properties.- Parameters:
direction
- must not be null.properties
- must not be null or empty.- Returns:
-
unsafe
Creates new unsafeSqlSort
based on givenSort.Direction
and properties.- Parameters:
direction
- must not be null.properties
- must not be null or empty.- Returns:
-
and
Returns a newSqlSort
with the given sorting criteria added to the current one.- Parameters:
direction
- can be null.paths
- must not be null.- Returns:
-
andUnsafe
Returns a newSqlSort
with the given sorting criteria added to the current one.- Parameters:
direction
- can be null.properties
- must not be null or empty.- Returns:
-