Top Description Methods
jakarta.data.repository

public @Interface Find

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:METHOD
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target

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:

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.

For example, consider an interface representing a garage:

@Repository
interface Garage {
    @Find
    List<Car> getCarsWithModel(@By("model") String model);
}

The @Find annotation indicates that the getCarsWithModel(model) method retrieves Car instances with the given value of the model field.

A method annotated with @Find must return one of the following types:

An automatic query method annotated Find returns an entity instance for every record which satisfies the parameter-based conditions.

Annotations such as @Find, @Query, @Insert, @Update, @Delete, and @Save are mutually-exclusive. A given method of a repository interface may have at most one @Find annotation, lifecycle annotation, or query annotation.

See Also
By, OrderBy

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString