Skip to content

@BindSqlSelect

xcesco edited this page Jan 24, 2017 · 9 revisions

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.

Query parameters

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>}

Return query result

There are many return type allowed for method which define a query:

  • a DAO's associated bean instance
  • list of associated bean
  • set of associated bean
  • Cursor: it is possible to wrap cursor with the cursor wrapper generated for bean associated to DAO. For example, given a Person and PersonDAO, will be generated BindPersonCursor.
  • It is possible to set return type as Void and define a OnReadBeanListener which a method void onRead(E bean, int row, int rowCount) allow to manage each row of result with only one bean (reused) instance.
  • It is possible to set return type as Void and define a OnReadCursorListener which a method void onRead(Cursor cursor) allows to manage resultset iteration with a cursor.

Example

Given a Java class definition:

@BindType
public class Person {
  public long id;
  public String name;
  public String surname;
  public String birthCity;
  public Date birthDay;
}

And a associated DAO definition:

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally