Annotation Interface Param


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

Annotates a parameter of a repository method to bind it to a named parameter of a Query.

For example,

 @Repository
 public interface Products extends BasicRepository<Product, String> {

     @Query("WHERE length * width * height <= :maxVolume ORDER BY price ASC, id ASC")
     Page<Product> freeShippingEligible(@Param("maxVolume") float volumeLimit,
                                        PageRequest pageRequest);

     ...
 }
 

The Param annotation is unnecessary when the method parameter name matches the query language named parameter name and the application is compiled with the -parameters compiler option making parameter names available at runtime.

See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Defines the name of the query language named parameter to bind to.
  • Element Details

    • value

      String value
      Defines the name of the query language named parameter to bind to.
      Returns:
      the name of the query language named parameter.