|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||
@Retention(value=RUNTIME) @Target(value=METHOD) public @interface Query
Defines a query method. Query methods normally use SQL select statements.
@Query(sql = "select id {int%%1}, name {%%.name} from person where id = {%1}")
Person getPerson(int id);
@Query(sql = "select id {%%.id,%%*}, name {%%.name} from person where id = {%1}")
Map<Integer, Person> getPerson(int id);
{%%.name} defines a result mapping to the setter setName on Person
{%%*} defines a the map ket for the colletion type Map using id
{int%%1} defines a result mapping to the first parameter of the
constructor of Person
{%1} defines a parameter mapping to the primitive type parameter id
Allowed return types of the query method are:
int, Double, String, etc. List collection with a generic type definition of one of the above typesSet collection with a generic type definition of one of the above typesMap collection with a generic type definition of one of the above types
and an atomic value object type or a value object mapped with custom mapping adapter as map key
SqlParser| Required Element Summary | |
|---|---|
String |
sql
This is the SQL statement. |
| Element Detail |
|---|
public abstract String sql
SqlParser
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||