Module jakarta.data

Annotation Interface By


@Retention(RUNTIME) @Target(PARAMETER) public @interface By

Annotates a parameter of a repository method to specify the name of an entity attribute against which to compare.

Example usage for a Person entity with attributes id, firstName, and lastName:

 @Repository
 public interface People extends BasicRepository<Person, Long> {

     List<Person> findNamed(@By("firstName") String first,
                            @By("lastName") String last);
 }
 ...
 found = people.findNamed(first, last);
 

The By annotation is unnecessary when the method parameter name matches the entity attribute name and the application is compiled with the -parameters compiler option that makes parameter names available at run time.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the entity attribute against which to compare.
  • Element Details

    • value

      String value
      The name of the entity attribute against which to compare.
      Returns:
      the entity attribute name.