|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.j256.ormlite.stmt.QueryBuilder<T,ID>
public class QueryBuilder<T,ID>
Assists in building SQL query (select) statements for a particular table in a particular database. Uses the
DatabaseType to get per-database SQL statements. By default the resulting queries will return objects with
all columns -- doing the equivalent of 'select * from table'. See columns(Iterable) or
columns(String...) to return partial column lists.
Here is a good tutorial of SQL commands.
| Nested Class Summary | |
|---|---|
static class |
QueryBuilder.InternalQueryBuilder<T,ID>
|
| Constructor Summary | |
|---|---|
QueryBuilder(DatabaseType databaseType,
TableInfo<T> tableInfo)
Provides statements for various SQL operations. |
|
| Method Summary | |
|---|---|
QueryBuilder<T,ID> |
columns(Iterable<String> columns)
Add columns to be returned by the query. |
QueryBuilder<T,ID> |
columns(String... columns)
Add columns to be returned by the query. |
QueryBuilder<T,ID> |
distinct()
Add "DISTINCT" clause to the SQL query statement. |
QueryBuilder<T,ID> |
groupBy(String columnName)
Add "GROUP BY" clauses to the SQL query statement. |
QueryBuilder<T,ID> |
limit(Integer maxRows)
Limit the output to maxRows maximum number of rows. |
QueryBuilder<T,ID> |
orderBy(String columnName,
boolean ascending)
Add "ORDER BY" clauses to the SQL query statement. |
PreparedQuery<T> |
prepareQuery()
Build and return a PreparedQuery object which then can be used by Dao.query(PreparedQuery) and
Dao.iterator(PreparedQuery) methods. |
String |
prepareQueryString()
Build and return a string version of the query. |
void |
setWhere(Where where)
Set the Where object on the query. |
Where |
where()
Returns a Where object that should be used to add SQL where clauses to the statement. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public QueryBuilder(DatabaseType databaseType,
TableInfo<T> tableInfo)
databaseType - Database type.tableInfo - Information about the table/class that is being handled.| Method Detail |
|---|
public QueryBuilder<T,ID> columns(String... columns)
public QueryBuilder<T,ID> columns(Iterable<String> columns)
public QueryBuilder<T,ID> groupBy(String columnName)
public QueryBuilder<T,ID> orderBy(String columnName,
boolean ascending)
public QueryBuilder<T,ID> distinct()
public QueryBuilder<T,ID> limit(Integer maxRows)
public Where where()
Where object that should be used to add SQL where clauses to the statement. This will also
reset the where object so you can use the same query builder with a different where statement.
public void setWhere(Where where)
Where object on the query. This allows someone to use the same Where object on multiple queries.
public PreparedQuery<T> prepareQuery()
PreparedQuery object which then can be used by Dao.query(PreparedQuery) and
Dao.iterator(PreparedQuery) methods. If you change the where or make other calls you will need to re-call
this method to re-prepare the query for execution.
public String prepareQueryString()
This is mostly used for debugging or logging cases. The dao classes us the prepareQuery() method.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||