@Retention(value=RUNTIME) @Target(value=METHOD) public @interface BindSqlSelect
Allow to query a database table. When you define the query through interface's method you can define query parameter by a DAO's associated bean instance, or directly with fields.
Almost all parameters used in method can be used as query parameter.
@BindSqlSelect(where = "name=${name} and surname=${surname}")
Person selectOne(String name, @BindSqlParam("surname") String temp);
Parameters of where condition are linked to method parameters
with the syntax ${<name of parameter>}
There are many return type allowed for method which define a query:
Person and
PersonDAO, will be generated BindPersonCursorOnReadBeanListener which a method
void onRead(E bean, int row, int rowCount) allow to manage each
row of result with only one bean (reused) instance.OnReadCursorListener which a method
void onRead(Cursor cursor) allows to manage resultset iteration
with a cursor.| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
distinct
if true, set distinct clause
|
String[] |
excludedFields
properties to exclude from SELECT statement.
|
String[] |
fields
properties to include into SELECT command
|
String |
groupBy
having statement
|
String |
having
having statement
|
String |
jql
JQL value.
|
String |
orderBy
order statement
|
int |
pageSize
Allow to define limit for query result.
|
String |
where
where condition
|
public abstract boolean distinct
public abstract String[] fields
public abstract String[] excludedFields
public abstract String where
public abstract String having
public abstract String groupBy
public abstract String orderBy
public abstract int pageSize
Allow to define limit for query result. Default no limit is defined.
public abstract String jql
JQL value. With this attribute, it is possibile to specify directly the JQL code. JQL means that you can write SQL using field's names and class name indeed
of column and table names. Moreover, it is possibile to specify where to use the dynamic parts of query through dynamic statements like DYNAMIC_WHERE, DYNAMIC_ORDER_BY, DYNAMIC_PAGE_SIZE, DYNAMIC_PAGE_OFFSET, encapsulated
in #{
For example, for a select statement, you can write:
SELECT * FROM media WHERE mediaId IN (SELECT mediaId FROM fav WHERE #{DYNAMIC_WHERE}) ORDER BY indx DESC LIMIT 0, 100
If you use this attribute, no other attributes can be defined for the annotation.Copyright © 2018. All rights reserved.