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>

public class SqlSort extends Sort
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:
  • Method Details

    • of

      public static SqlSort of(String... paths)
      Parameters:
      paths - must not be null or empty.
    • of

      public static SqlSort of(Sort.Direction direction, String... paths)
      Parameters:
      direction - the sorting direction.
      paths - must not be null or empty.
    • validate

      public static void validate(Sort.Order order)
      Validates a Sort.Order, to be either safe for use in SQL or to be explicitely marked unsafe.
      Parameters:
      order - the Sort.Order to validate. Must not be null.
    • unsafe

      public static SqlSort unsafe(String... properties)
      Creates new unsafe SqlSort based on given properties.
      Parameters:
      properties - must not be null or empty.
      Returns:
    • unsafe

      public static SqlSort unsafe(Sort.Direction direction, String... properties)
      Creates new unsafe SqlSort based on given Sort.Direction and properties.
      Parameters:
      direction - must not be null.
      properties - must not be null or empty.
      Returns:
    • unsafe

      public static SqlSort unsafe(Sort.Direction direction, List<String> properties)
      Creates new unsafe SqlSort based on given Sort.Direction and properties.
      Parameters:
      direction - must not be null.
      properties - must not be null or empty.
      Returns:
    • and

      public SqlSort and(@Nullable Sort.Direction direction, String... paths)
      Returns a new SqlSort with the given sorting criteria added to the current one.
      Parameters:
      direction - can be null.
      paths - must not be null.
      Returns:
    • andUnsafe

      public SqlSort andUnsafe(@Nullable Sort.Direction direction, String... properties)
      Returns a new SqlSort with the given sorting criteria added to the current one.
      Parameters:
      direction - can be null.
      properties - must not be null or empty.
      Returns: