Package com.bld.proxy.api.find.config
Annotation Interface ApiQuery
Specifies an explicit query string to be executed by the
proxy-api-controller interceptor instead of relying on the
automatic JPQL generation.
When this annotation is absent the framework generates a JPQL query
dynamically from the method's ApiFind
binding and the parameters present in the request. When @ApiQuery is
present, its value() is used as-is (either as a native SQL or JPQL
string depending on the jpql() flag).
Native SQL example
@GetMapping("/products/custom")
@ApiQuery("SELECT * FROM product WHERE active = true")
List<ProductDto> findActive();
JPQL example
@GetMapping("/products/custom")
@ApiQuery(value = "SELECT p FROM Product p WHERE p.active = true", jpql = true)
List<ProductDto> findActive();
- Author:
- Francesco Baldi
- See Also:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhentrue, thevalue()is treated as a JPQL query and the automatic query-building pipeline is used.Default ordering to apply when the caller has not specified a sort key.
-
Element Details
-
value
String valueThe query string to execute. For native SQL queries this must be a valid SQL statement; for JPQL queries (jpql()=true) it must be a valid JPQL statement.- Returns:
- the query string; must not be blank when
jpql()isfalse
-
jpql
boolean jpqlWhentrue, thevalue()is treated as a JPQL query and the automatic query-building pipeline is used. Whenfalse(default),value()is executed as a native SQL query.- Returns:
truefor JPQL mode,falsefor native SQL mode
- Default:
false
-
orderBy
DefaultOrderBy[] orderByDefault ordering to apply when the caller has not specified a sort key. Each entry maps to oneORDER BYclause item.- Returns:
- the default order-by clauses; empty array means no default ordering
- Default:
{}
-