public class FluentQuery
extends java.lang.Object
| 限定符和类型 | 方法和说明 |
|---|---|
double |
average(java.lang.Class<?> modelClass,
java.lang.String column)
Calculates the average value on a given column.
|
double |
average(java.lang.String tableName,
java.lang.String column)
Calculates the average value on a given column.
|
AverageExecutor |
averageAsync(java.lang.Class<?> modelClass,
java.lang.String column)
已过时。
|
AverageExecutor |
averageAsync(java.lang.String tableName,
java.lang.String column)
已过时。
|
int |
count(java.lang.Class<?> modelClass)
Count the records.
|
int |
count(java.lang.String tableName)
Count the records.
|
CountExecutor |
countAsync(java.lang.Class<?> modelClass)
已过时。
|
CountExecutor |
countAsync(java.lang.String tableName)
已过时。
|
<T> java.util.List<T> |
find(java.lang.Class<T> modelClass)
Finds multiple records by the cluster parameters.
|
<T> java.util.List<T> |
find(java.lang.Class<T> modelClass,
boolean isEager)
It is mostly same as
find(Class) but an isEager
parameter. |
<T> FindMultiExecutor<T> |
findAsync(java.lang.Class<T> modelClass)
已过时。
|
<T> FindMultiExecutor<T> |
findAsync(java.lang.Class<T> modelClass,
boolean isEager)
已过时。
|
<T> T |
findFirst(java.lang.Class<T> modelClass)
Finds the first record by the cluster parameters.
|
<T> T |
findFirst(java.lang.Class<T> modelClass,
boolean isEager)
It is mostly same as
findFirst(Class) but an isEager
parameter. |
<T> FindExecutor<T> |
findFirstAsync(java.lang.Class<T> modelClass)
已过时。
|
<T> FindExecutor<T> |
findFirstAsync(java.lang.Class<T> modelClass,
boolean isEager)
已过时。
|
<T> T |
findLast(java.lang.Class<T> modelClass)
Finds the last record by the cluster parameters.
|
<T> T |
findLast(java.lang.Class<T> modelClass,
boolean isEager)
It is mostly same as
findLast(Class) but an isEager
parameter. |
<T> FindExecutor<T> |
findLastAsync(java.lang.Class<T> modelClass)
已过时。
|
<T> FindExecutor<T> |
findLastAsync(java.lang.Class<T> modelClass,
boolean isEager)
已过时。
|
FluentQuery |
limit(int value)
Limits the number of rows returned by the query.
|
<T> T |
max(java.lang.Class<?> modelClass,
java.lang.String columnName,
java.lang.Class<T> columnType)
Calculates the maximum value on a given column.
|
<T> T |
max(java.lang.String tableName,
java.lang.String columnName,
java.lang.Class<T> columnType)
Calculates the maximum value on a given column.
|
<T> FindExecutor<T> |
maxAsync(java.lang.Class<?> modelClass,
java.lang.String columnName,
java.lang.Class<T> columnType)
已过时。
|
<T> FindExecutor<T> |
maxAsync(java.lang.String tableName,
java.lang.String columnName,
java.lang.Class<T> columnType)
已过时。
|
<T> T |
min(java.lang.Class<?> modelClass,
java.lang.String columnName,
java.lang.Class<T> columnType)
Calculates the minimum value on a given column.
|
<T> T |
min(java.lang.String tableName,
java.lang.String columnName,
java.lang.Class<T> columnType)
Calculates the minimum value on a given column.
|
<T> FindExecutor<T> |
minAsync(java.lang.Class<?> modelClass,
java.lang.String columnName,
java.lang.Class<T> columnType)
已过时。
|
<T> FindExecutor<T> |
minAsync(java.lang.String tableName,
java.lang.String columnName,
java.lang.Class<T> columnType)
已过时。
|
FluentQuery |
offset(int value)
Declaring the offset of rows returned by the query.
|
FluentQuery |
order(java.lang.String column)
Declaring how to order the rows queried from table.
|
FluentQuery |
select(java.lang.String... columns)
Declaring to query which columns in table.
|
<T> T |
sum(java.lang.Class<?> modelClass,
java.lang.String columnName,
java.lang.Class<T> columnType)
Calculates the sum of values on a given column.
|
<T> T |
sum(java.lang.String tableName,
java.lang.String columnName,
java.lang.Class<T> columnType)
Calculates the sum of values on a given column.
|
<T> FindExecutor<T> |
sumAsync(java.lang.Class<?> modelClass,
java.lang.String columnName,
java.lang.Class<T> columnType)
已过时。
|
<T> FindExecutor<T> |
sumAsync(java.lang.String tableName,
java.lang.String columnName,
java.lang.Class<T> columnType)
已过时。
|
FluentQuery |
where(java.lang.String... conditions)
Declaring to query which rows in table.
|
public FluentQuery select(java.lang.String... columns)
LitePal.select("name", "age").find(Person.class);
This will find all rows with name and age columns in Person table.columns - A String array of which columns to return. Passing null will
return all columns.public FluentQuery where(java.lang.String... conditions)
LitePal.where("name = ? or age > ?", "Tom", "14").find(Person.class);
This will find rows which name is Tom or age greater than 14 in Person
table.conditions - A filter declaring which rows to return, formatted as an SQL
WHERE clause. Passing null will return all rows.public FluentQuery order(java.lang.String column)
LitePal.order("name desc").find(Person.class);
This will find all rows in Person table sorted by name with inverted
order.column - How to order the rows, formatted as an SQL ORDER BY clause.
Passing null will use the default sort order, which may be
unordered.public FluentQuery limit(int value)
LitePal.limit(2).find(Person.class);This will find the top 2 rows in Person table.
value - Limits the number of rows returned by the query, formatted as
LIMIT clause.public FluentQuery offset(int value)
limit(int), or nothing will return.
LitePal.limit(1).offset(2).find(Person.class);This will find the third row in Person table.
value - The offset amount of rows returned by the query.public <T> java.util.List<T> find(java.lang.Class<T> modelClass)
LitePal.select("name").where("age > ?", "14").order("age").limit(1).offset(2)
.find(Person.class);
You can also do the same job with SQLiteDatabase like this:
getSQLiteDatabase().query("Person", "name", "age > ?", new String[] { "14" }, null, null, "age",
"2,1");
Obviously, the first way is much more semantic.find(Class, boolean).modelClass - Which table to query and the object type to return as a list.@Deprecated public <T> FindMultiExecutor<T> findAsync(java.lang.Class<T> modelClass)
public <T> java.util.List<T> find(java.lang.Class<T> modelClass,
boolean isEager)
find(Class) but an isEager
parameter. If set true the associated models will be loaded as well.
modelClass - Which table to query and the object type to return as a list.isEager - True to load the associated models, false not.@Deprecated public <T> FindMultiExecutor<T> findAsync(java.lang.Class<T> modelClass, boolean isEager)
public <T> T findFirst(java.lang.Class<T> modelClass)
LitePal.select("name").where("age > ?", "14").order("age").limit(10).offset(2)
.findFirst(Person.class);
Note that the associated models won't be loaded by default considering
the efficiency, but you can do that by using
findFirst(Class, boolean).modelClass - Which table to query and the object type to return.@Deprecated public <T> FindExecutor<T> findFirstAsync(java.lang.Class<T> modelClass)
public <T> T findFirst(java.lang.Class<T> modelClass,
boolean isEager)
findFirst(Class) but an isEager
parameter. If set true the associated models will be loaded as well.
modelClass - Which table to query and the object type to return.isEager - True to load the associated models, false not.@Deprecated public <T> FindExecutor<T> findFirstAsync(java.lang.Class<T> modelClass, boolean isEager)
public <T> T findLast(java.lang.Class<T> modelClass)
LitePal.select("name").where("age > ?", "14").order("age").limit(10).offset(2)
.findLast(Person.class);
Note that the associated models won't be loaded by default considering
the efficiency, but you can do that by using
findLast(Class, boolean).modelClass - Which table to query and the object type to return.@Deprecated public <T> FindExecutor<T> findLastAsync(java.lang.Class<T> modelClass)
public <T> T findLast(java.lang.Class<T> modelClass,
boolean isEager)
findLast(Class) but an isEager
parameter. If set true the associated models will be loaded as well.
modelClass - Which table to query and the object type to return.isEager - True to load the associated models, false not.@Deprecated public <T> FindExecutor<T> findLastAsync(java.lang.Class<T> modelClass, boolean isEager)
public int count(java.lang.Class<?> modelClass)
LitePal.count(Person.class);This will count all rows in person table.
LitePal.where("age > ?", "15").count(Person.class);
modelClass - Which table to query from by class.@Deprecated public CountExecutor countAsync(java.lang.Class<?> modelClass)
public int count(java.lang.String tableName)
LitePal.count("person");
This will count all rows in person table.
LitePal.where("age > ?", "15").count("person");
tableName - Which table to query from.@Deprecated public CountExecutor countAsync(java.lang.String tableName)
public double average(java.lang.Class<?> modelClass,
java.lang.String column)
LitePal.average(Person.class, "age");You can also specify a where clause when calculating.
LitePal.where("age > ?", "15").average(Person.class, "age");
modelClass - Which table to query from by class.column - The based on column to calculate.@Deprecated public AverageExecutor averageAsync(java.lang.Class<?> modelClass, java.lang.String column)
public double average(java.lang.String tableName,
java.lang.String column)
LitePal.average("person", "age");
You can also specify a where clause when calculating.
LitePal.where("age > ?", "15").average("person", "age");
tableName - Which table to query from.column - The based on column to calculate.@Deprecated public AverageExecutor averageAsync(java.lang.String tableName, java.lang.String column)
public <T> T max(java.lang.Class<?> modelClass,
java.lang.String columnName,
java.lang.Class<T> columnType)
LitePal.max(Person.class, "age", int.class);You can also specify a where clause when calculating.
LitePal.where("age > ?", "15").max(Person.class, "age", Integer.TYPE);
modelClass - Which table to query from by class.columnName - The based on column to calculate.columnType - The type of the based on column.@Deprecated public <T> FindExecutor<T> maxAsync(java.lang.Class<?> modelClass, java.lang.String columnName, java.lang.Class<T> columnType)
public <T> T max(java.lang.String tableName,
java.lang.String columnName,
java.lang.Class<T> columnType)
LitePal.max("person", "age", int.class);
You can also specify a where clause when calculating.
LitePal.where("age > ?", "15").max("person", "age", Integer.TYPE);
tableName - Which table to query from.columnName - The based on column to calculate.columnType - The type of the based on column.@Deprecated public <T> FindExecutor<T> maxAsync(java.lang.String tableName, java.lang.String columnName, java.lang.Class<T> columnType)
public <T> T min(java.lang.Class<?> modelClass,
java.lang.String columnName,
java.lang.Class<T> columnType)
LitePal.min(Person.class, "age", int.class);You can also specify a where clause when calculating.
LitePal.where("age > ?", "15").min(Person.class, "age", Integer.TYPE);
modelClass - Which table to query from by class.columnName - The based on column to calculate.columnType - The type of the based on column.@Deprecated public <T> FindExecutor<T> minAsync(java.lang.Class<?> modelClass, java.lang.String columnName, java.lang.Class<T> columnType)
public <T> T min(java.lang.String tableName,
java.lang.String columnName,
java.lang.Class<T> columnType)
LitePal.min("person", "age", int.class);
You can also specify a where clause when calculating.
LitePal.where("age > ?", "15").min("person", "age", Integer.TYPE);
tableName - Which table to query from.columnName - The based on column to calculate.columnType - The type of the based on column.@Deprecated public <T> FindExecutor<T> minAsync(java.lang.String tableName, java.lang.String columnName, java.lang.Class<T> columnType)
public <T> T sum(java.lang.Class<?> modelClass,
java.lang.String columnName,
java.lang.Class<T> columnType)
LitePal.sum(Person.class, "age", int.class);You can also specify a where clause when calculating.
LitePal.where("age > ?", "15").sum(Person.class, "age", Integer.TYPE);
modelClass - Which table to query from by class.columnName - The based on column to calculate.columnType - The type of the based on column.@Deprecated public <T> FindExecutor<T> sumAsync(java.lang.Class<?> modelClass, java.lang.String columnName, java.lang.Class<T> columnType)
public <T> T sum(java.lang.String tableName,
java.lang.String columnName,
java.lang.Class<T> columnType)
LitePal.sum("person", "age", int.class);
You can also specify a where clause when calculating.
LitePal.where("age > ?", "15").sum("person", "age", Integer.TYPE);
tableName - Which table to query from.columnName - The based on column to calculate.columnType - The type of the based on column.@Deprecated public <T> FindExecutor<T> sumAsync(java.lang.String tableName, java.lang.String columnName, java.lang.Class<T> columnType)