net.aditsu.depeche
public class Query extends SQLQuery implements DynamicQuery
| Modifier and Type | Method and Description |
|---|---|
Query |
copy()
Returns a copy of this query, without any cached results
|
int |
count()
Returns the number of rows that this SELECT query would find, as an int value.
|
int |
count(Conn conn)
Returns the number of rows that this SELECT query would find, as an int value.
|
int |
delete()
Runs this query as a DELETE query and returns the number of rows
|
int |
delete(Conn conn)
Runs this query as a DELETE query using the given connection and returns the number of rows
|
Query |
desc(List<String> fields)
Adds the given fields (descending) to the list of fields to sort by, and returns a new query
|
Query |
desc(String... fields)
Adds the given fields (descending) to the list of fields to sort by, and returns a new query
|
Query |
distinct()
Adds the "DISTINCT" clause to the query, and returns a new query
|
Query |
exclude(Condition cond)
Adds the negation of a condition to this query (using "AND" with an existing condition)
and returns a new query
|
Query |
exclude(KeyInfo keyInfo,
Key key)
Adds a condition to NOT match a list of columns with a list of values, and returns a new query
|
Query |
exclude(SQLCondition cond)
Adds the negation of a SQL condition to this query (using "AND" with an existing condition)
and returns a new query
|
Query |
exclude(String name,
Serializable value)
Adds a condition that the column with the given name should NOT have the given value, and returns a new query
|
Query |
exclude(String name,
String op,
Serializable value)
Adds a negative "name operator value" condition and returns a new query
|
Query |
excludeIn(String name,
Collection<? extends Serializable> values)
Adds a negative "name IN (values)" condition and returns a new query
|
Query |
field(String field,
String alias)
Adds "field AS alias" to the list of fields to select in each record, and returns a new query
|
Query |
fields(List<String> fields)
Adds the given fields to the list of fields to select in each record, and returns a new query
|
Query |
fields(List<String> fields,
List<String> aliases)
Adds the given fields with the given aliases to the list of fields to select in each record, and returns a new query
|
Query |
fields(String... fields)
Adds the given fields to the list of fields to select in each record, and returns a new query
|
Query |
filter(Condition cond)
Adds a condition to this query (using "AND" with an existing condition) and returns a new query
|
Query |
filter(KeyInfo keyInfo,
Key key)
Adds a condition to match a list of columns with a list of values, and returns a new query
|
Query |
filter(Record rec,
KeyInfo cols)
Adds a condition to match a list of columns with a list of corresponding values from a Record,
and returns a new query
|
Query |
filter(Record rec,
String... cols)
Adds a condition to match a list of columns with a list of corresponding values from a Record,
and returns a new query
|
Query |
filter(SQLCondition cond)
Adds a SQL condition to this query (using "AND" with an existing condition) and returns a new query
|
Query |
filter(String name,
Serializable value)
Adds a condition that the column with the given name should have the given value, and returns a new query
|
Query |
filter(String name,
String op,
Serializable value)
Adds a "name operator value" condition and returns a new query
|
Query |
filterIn(String name,
Collection<? extends Serializable> values)
Adds a "name IN (values)" condition and returns a new query
|
Query |
filterPK(List<Serializable> values)
Adds a condition that matches the primary key columns of the query's table to the given values
and returns a new query
|
Query |
filterPK(Serializable... values)
Adds a condition that matches the primary key columns of the query's table to the given values
and returns a new query
|
String |
getDeleteSQL()
Returns the SQL string for running this query as a DELETE query
|
String |
getInsertSQL()
Returns the SQL string for running this query as an INSERT query
|
List<Serializable> |
getParams()
Returns this query's parameters
|
String |
getSelectSQL()
Returns the SQL string for running this query as a SELECT query
|
String |
getTable()
Returns the main table being queried
|
String |
getUpdateSQL()
Returns the SQL string for running this query as an UPDATE query
|
int |
insert()
Runs this query as an INSERT query and returns the number of rows
|
int |
insert(Conn conn)
Runs this query as an INSERT query using the given connection and returns the number of rows
|
boolean |
isLimited()
Returns true if this query has a limit or offset
|
Query |
join(Join join)
Adds the given join object to the query's joins and returns a new query
|
Query |
join(JoinType type,
String table,
String fld1,
String fld2)
Adds a join of a given type, with a given table, with the condition that the
two given fields are equal, and returns a new query; all parameters are quoted
|
Query |
join(String table,
String fld1,
String fld2)
Adds an inner join with a given table, with the condition that the two given fields are equal,
and returns a new query; all parameters are quoted
|
Query |
joinParent(FKey fk)
Adds an inner join with a parent table, linked through the given foreign key
|
Query |
joinParent(JoinType type,
FKey fk)
Adds a join of a given type, with a parent table, linked through the given foreign key
|
Query |
joinParentFrom(JoinType type,
String table)
Adds a join of a given type, with the given parent table, linked through a foreign key
|
Query |
joinParentFrom(String table)
Adds an inner join with the given parent table, linked through a foreign key
|
Query |
joinParents()
Adds inner joins with all parent tables, linked through foreign keys
|
Query |
joinParents(JoinType type)
Adds joins of a given type, with all parent tables, linked through foreign keys
|
Query |
joinParentThrough(JoinType type,
String column)
Adds a join of a given type, with a parent table, linked through the given column
|
Query |
joinParentThrough(String column)
Adds an inner join with a parent table, linked through the given column
|
Query |
leftJoin(String table,
String fld1,
String fld2)
Adds a left join with a given table, with the condition that the two given fields are equal,
and returns a new query; all parameters are quoted
|
Query |
leftJoinParent(FKey fk)
Adds a left join with a parent table, linked through the given foreign key
|
Query |
leftJoinParentFrom(String table)
Adds a left join with the given parent table, linked through a foreign key
|
Query |
leftJoinParents()
Adds left joins with all parent tables, linked through foreign keys
|
Query |
leftJoinParentThrough(String column)
Adds a left join with a parent table, linked through the given column
|
Query |
limit(long x)
Limits the number of records to select and returns a new query
|
Query |
lock(RowLock rowLock)
Sets the given row lock (for SELECT) and returns a new query
|
long |
longCount()
Returns the number of rows that this SELECT query would find, as a long value.
|
long |
longCount(Conn conn)
Returns the number of rows that this SELECT query would find, as a long value.
|
Query |
offset(long x)
Sets the offset of the first record to select (i.e.
|
Query |
order(List<String> fields)
Adds the given fields (ascending) to the list of fields to sort by, and returns a new query
|
Query |
order(String... fields)
Adds the given fields (ascending) to the list of fields to sort by, and returns a new query
|
Query |
rawFields(String... fields)
Adds the given raw SQL expressions to the "SELECT" clause and returns a new query
|
Query |
rawFilter(String sql,
Serializable... params)
Creates a custom condition and adds it to this query (using "AND" with an existing condition)
and returns a new query
|
Query |
rawJoin(String table,
String fld1,
String fld2)
Adds an inner join with a given table, with the condition that the two given fields are equal,
and returns a new query; all parameters are taken as raw SQL expressions
|
Query |
rawOrder(String... fields)
Adds the given raw SQL expressions to the "ORDER BY" clause and returns a new query
|
Query |
rawSet(String name,
Serializable value)
Adds a field value (for INSERT or UPDATE) using a raw expression for the field, and returns a new query
|
Query |
select()
Runs this query as a SELECT (and caches the results)
|
Query |
select(Conn conn)
Runs this query as a SELECT using the given connection (and caches the results)
|
Query |
set(String name,
Serializable value)
Adds a field value (for INSERT or UPDATE) and returns a new query
|
Query |
setExpr(String fieldExpr,
String valueExpr,
Serializable... params)
Adds a field value (for INSERT or UPDATE) using raw expressions for both the field and the value, and returns a new query
|
void |
startDeleteBatch(Conn conn,
boolean keepParams)
Starts a batch DELETE using this query and the given connection
|
void |
startInsertBatch(Conn conn,
boolean keepParams)
Starts a batch INSERT using this query and the given connection
|
void |
startUpdateBatch(Conn conn,
boolean keepParams)
Starts a batch UPDATE using this query and the given connection
|
Query |
table(String tableName)
Sets the table to be queried and returns a new query
|
Query |
table(Table t)
Sets the table to be queried and returns a new query
|
addParams, executeBatch, getOneRecord, getProvider, getProviderRef, getRecord, update, updateclearData, get, getColumn, getColumn, getColumn, getColumn, getColumnInfo, getLocalQuery, getOneRecord, getRecord, hasRun, sizeadd, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, set, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclearData, getColumn, getColumn, getColumn, getColumn, getColumnInfo, getLocalQuery, getOneRecord, getRecord, hasRunpublic Query copy()
DynamicQuerycopy in interface DynamicQuerypublic Query select(Conn conn)
SQLQuerypublic Query select()
SQLQuerypublic Query filter(String name, Serializable value)
filter in interface DynamicQueryProvider.filter(String, Serializable)public Query filter(KeyInfo keyInfo, Key key)
filter in interface DynamicQueryProvider.filter(KeyInfo, Key)public Query filter(Record rec, KeyInfo cols)
DynamicQueryfilter in interface DynamicQuerypublic Query filter(Record rec, String... cols)
DynamicQueryfilter in interface DynamicQuerypublic Query filterIn(String name, Collection<? extends Serializable> values)
filterIn in interface DynamicQueryProvider.filterIn(String, Collection)public Query exclude(String name, Serializable value)
exclude in interface DynamicQueryProvider.filter(String, Serializable)public Query exclude(KeyInfo keyInfo, Key key)
exclude in interface DynamicQueryProvider.filter(KeyInfo, Key)public Query excludeIn(String name, Collection<? extends Serializable> values)
excludeIn in interface DynamicQueryProvider.filterIn(String, Collection)public Query filter(String name, String op, Serializable value)
filter in interface DynamicQueryProvider.filter(String, String, Serializable)public Query exclude(String name, String op, Serializable value)
exclude in interface DynamicQueryProvider.filter(String, String, Serializable)public Query filterPK(Serializable... values)
public Query filterPK(List<Serializable> values)
public Query filter(SQLCondition cond)
public Query filter(Condition cond)
DynamicQueryfilter in interface DynamicQuerypublic Query exclude(SQLCondition cond)
public Query exclude(Condition cond)
DynamicQueryexclude in interface DynamicQuerypublic Query rawFilter(String sql, Serializable... params)
public String getSelectSQL()
SQLQuerygetSelectSQL in class SQLQuerypublic String getDeleteSQL()
public String getUpdateSQL()
getUpdateSQL in class SQLQuerypublic String getInsertSQL()
public List<Serializable> getParams()
SQLQuerypublic Query limit(long x)
DynamicQuerylimit in interface DynamicQuerypublic Query offset(long x)
DynamicQueryoffset in interface DynamicQuerypublic Query order(String... fields)
DynamicQueryorder in interface DynamicQuerypublic Query order(List<String> fields)
DynamicQueryorder in interface DynamicQuerypublic Query desc(String... fields)
DynamicQuerydesc in interface DynamicQuerypublic Query desc(List<String> fields)
DynamicQuerydesc in interface DynamicQuerypublic Query rawOrder(String... fields)
public Query fields(String... fields)
DynamicQueryfields in interface DynamicQuerypublic Query fields(List<String> fields)
DynamicQueryfields in interface DynamicQuerypublic Query field(String field, String alias)
DynamicQueryfield in interface DynamicQuerypublic Query fields(List<String> fields, List<String> aliases)
DynamicQueryfields in interface DynamicQuerypublic Query rawFields(String... fields)
public Query set(String name, Serializable value)
public Query rawSet(String name, Serializable value)
public Query setExpr(String fieldExpr, String valueExpr, Serializable... params)
public int insert()
public int insert(Conn conn)
public int delete()
public int delete(Conn conn)
public int count()
BaseQuery.size() if the query has already run, otherwise runs a separate
"SELECT COUNT(*)" query.count in interface DynamicQuerypublic int count(Conn conn)
BaseQuery.size() if the query has already run, otherwise runs a separate
"SELECT COUNT(*)" query using the given connection.public long longCount()
BaseQuery.size() if the query has already run, otherwise runs a separate
"SELECT COUNT(*)" query.longCount in interface DynamicQuerypublic long longCount(Conn conn)
BaseQuery.size() if the query has already run, otherwise runs a separate
"SELECT COUNT(*)" query using the given connection.public void startInsertBatch(Conn conn, boolean keepParams)
conn - connection to use for preparing the statementkeepParams - true to keep this query's parameters as the first set of parameters in the batchpublic void startUpdateBatch(Conn conn, boolean keepParams)
conn - connection to use for preparing the statementkeepParams - true to keep this query's parameters as the first set of parameters in the batchpublic void startDeleteBatch(Conn conn, boolean keepParams)
conn - connection to use for preparing the statementkeepParams - true to keep this query's parameters as the first set of parameters in the batchpublic Query join(Join join)
public Query rawJoin(String table, String fld1, String fld2)
public Query join(JoinType type, String table, String fld1, String fld2)
public Query join(String table, String fld1, String fld2)
public Query leftJoin(String table, String fld1, String fld2)
public Query joinParent(JoinType type, FKey fk)
public Query joinParent(FKey fk)
public Query leftJoinParent(FKey fk)
public Query joinParents(JoinType type)
public Query joinParents()
public Query leftJoinParents()
public Query joinParentFrom(JoinType type, String table)
public Query joinParentFrom(String table)
public Query leftJoinParentFrom(String table)
public Query joinParentThrough(JoinType type, String column)
public Query joinParentThrough(String column)
public Query leftJoinParentThrough(String column)
public String getTable()
public Query distinct()
DynamicQuerydistinct in interface DynamicQuerypublic Query lock(RowLock rowLock)
public boolean isLimited()