Annotation Interface DefaultOrderBy


@Retention(RUNTIME) public @interface DefaultOrderBy
Defines a default ORDER BY clause for an ApiQuery-annotated method.

Multiple @DefaultOrderBy entries can be combined inside ApiQuery.orderBy() to produce a multi-column sort. The default ordering is applied only when the caller has not provided an explicit sort key via the sortKey / orderType request parameters.

Example


 @GetMapping("/products")
 @ApiQuery(
     value  = "SELECT p FROM Product p",
     jpql   = true,
     orderBy = {
         @DefaultOrderBy(value = "p.name", orderType = OrderType.asc),
         @DefaultOrderBy(value = "p.price", orderType = OrderType.desc)
     }
 )
 List<ProductDto> findAll();
 
Author:
Francesco Baldi
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The JPQL or SQL expression to sort by (e.g., "p.name" or "price").
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The sort direction.
  • Element Details

    • value

      String value
      The JPQL or SQL expression to sort by (e.g., "p.name" or "price").
      Returns:
      the sort expression; must not be blank
    • orderType

      OrderType orderType
      The sort direction. Defaults to OrderType.asc.
      Returns:
      the order direction
      Default:
      asc