Annotation Interface Find


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface Find

Annotates a repository method returning entities as a parameter-based automatic query method.

The Find annotation indicates that the annotated repository method executes a query to retrieve entities based on its parameters and on the arguments assigned to its parameters. The method return type identifies the entity type returned by the query. Each parameter of the annotated method must either:

  • have exactly the same type and name (the parameter name in the Java source, or a name assigned by @By) as a persistent field or property of the entity class, or

The query is inferred from the method parameters which match persistent fields of the entity.

There is no specific naming convention for methods annotated with @Find; they may be named arbitrarily, and their names do not carry any semantic meaning defined by the Jakarta Data specification.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optionally specifies the queried entity type.
  • Element Details

    • value

      Class<?> value

      Optionally specifies the queried entity type.

      The default value, void.class, has the special meaning of determining the entity type from the method return type if the method returns entities, and otherwise from the primary entity type of the repository.

      A repository method with the Find annotation must specify a valid entity class as the value if the method does not return entities and the repository does not otherwise define a primary entity type.

      For example,

       @Repository
       public interface Vehicles {
           @Find(Car.class)
           Optional<Car> findCar(@By(_Car.VIN) String vehicleIdNum);
      
           ...
       }
       
      Returns:
      The entity type
      Since:
      5.0
      Default:
      void.class