Module jakarta.data

Annotation Interface First


@Retention(RUNTIME) @Target(METHOD) public @interface First

Specifies a static limit on the number of results retrieved by a repository method. The results of a single invocation of a repository method may be limited to a given maximum number of results. For example,


 @Find @First
 @OrderBy(value = _Employee.SALARY, descending = true)
 Employee highestPaid(String jobTitle);
 

 @First(10)
 @Query("order by playCount desc")
 List<Song> topTen();
 

A repository method may not be declared with:

  • a @First annotation and a parameter of type PageRequest or Limit, or
  • a @First annotation in combination with the First keyword.
Since:
1.1
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    The limit on the number of results returned by the repository method.
  • Element Details

    • value

      int value
      The limit on the number of results returned by the repository method. Must be strictly positive.
      Default:
      1