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
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 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, String... paths) Returns a newSqlSortwith the given sorting criteria added to the current one.andUnsafe(@Nullable 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 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
- 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
-
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:
-