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
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.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 newSqlSortwith the given sorting criteria added to the current one.andUnsafe(Sort.Direction direction, String... properties) Returns a newSqlSortwith the given sorting criteria added to the current one.static SqlSortstatic SqlSortof(Sort.Direction direction, String... paths) static SqlSortCreates new unsafeSqlSortbased on given properties.static SqlSortunsafe(Sort.Direction direction, String... properties) Creates new unsafeSqlSortbased on givenSort.Directionand properties.static SqlSortunsafe(Sort.Direction direction, List<String> properties) Creates new unsafeSqlSortbased on givenSort.Directionand properties.static voidvalidate(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, unsortedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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.Orderto validate. Must not be null.
-
unsafe
Creates new unsafeSqlSortbased on given properties.- Parameters:
properties- must not be null or empty.- Returns:
-
unsafe
Creates new unsafeSqlSortbased on givenSort.Directionand properties.- Parameters:
direction- must not be null.properties- must not be null or empty.- Returns:
-
unsafe
Creates new unsafeSqlSortbased on givenSort.Directionand properties.- Parameters:
direction- must not be null.properties- must not be null or empty.- Returns:
-
and
Returns a newSqlSortwith the given sorting criteria added to the current one.- Parameters:
direction- can be null.paths- must not be null.- Returns:
-
andUnsafe
Returns a newSqlSortwith the given sorting criteria added to the current one.- Parameters:
direction- can be null.properties- must not be null or empty.- Returns:
-