public class Query extends Object implements Serializable
Use with DatabaseProvider.renderQuery(Query, net.java.ao.schema.TableNameConverter, boolean)
to produce the database-specific SQL.
Modifier and Type | Class and Description |
---|---|
static class |
Query.QueryType |
Constructor and Description |
---|
Query(Query.QueryType type,
String fields)
Create a
Query and set the field list in the SELECT clause. |
Modifier and Type | Method and Description |
---|---|
Query |
alias(Class<? extends RawEntity<?>> table,
String alias) |
Query |
distinct() |
Query |
from(Class<? extends RawEntity<?>> tableType) |
Query |
from(String table) |
String |
getAlias(Class<? extends RawEntity<?>> table) |
String[] |
getCanonicalFields(EntityInfo<?,?> entityInfo) |
Iterable<String> |
getFields() |
String |
getGroupClause() |
String |
getHavingClause() |
Map<Class<? extends RawEntity<?>>,String> |
getJoins() |
int |
getLimit() |
int |
getOffset() |
String |
getOrderClause() |
String |
getTable() |
Class<? extends RawEntity<?>> |
getTableType() |
Query.QueryType |
getType() |
String |
getWhereClause() |
Object[] |
getWhereParams() |
Query |
group(String clause) |
Query |
having(String clause) |
boolean |
isDistinct() |
Query |
join(Class<? extends RawEntity<?>> join) |
Query |
join(Class<? extends RawEntity<?>> join,
String on) |
Query |
limit(int limit) |
Query |
offset(int offset) |
Query |
order(String clause) |
static Query |
select()
Create a
Query which will select the primary key field of the entity. |
static Query |
select(String fields)
Create a
Query and set the field list in the SELECT clause. |
void |
setDistinct(boolean distinct) |
void |
setGroupClause(String groupClause) |
void |
setHavingClause(String havingClause) |
void |
setJoins(Map<Class<? extends RawEntity<?>>,String> joins) |
void |
setLimit(int limit) |
void |
setOffset(int offset) |
void |
setOrderClause(String orderClause) |
protected void |
setParameters(EntityManager manager,
PreparedStatement stmt) |
void |
setTable(String table) |
void |
setTableType(Class<? extends RawEntity<?>> tableType) |
void |
setWhereClause(String whereClause) |
void |
setWhereParams(Object[] whereParams) |
protected <K> String |
toSQL(EntityInfo<? extends RawEntity<K>,K> entityInfo,
DatabaseProvider provider,
TableNameConverter converter,
boolean count) |
Query |
where(String clause,
Object... params) |
public Query(Query.QueryType type, String fields)
Query
and set the field list in the SELECT
clause.fields
- The fields to select, as comma-delimited field names. Spaces are OK. Must not contain "*"
.IllegalArgumentException
- if fields contains "*"
public Query distinct()
public Query limit(int limit)
public Query offset(int offset)
public boolean isDistinct()
public void setDistinct(boolean distinct)
public String getTable()
public void setTable(String table)
public String getWhereClause()
public void setWhereClause(String whereClause)
public Object[] getWhereParams()
public void setWhereParams(Object[] whereParams)
public String getOrderClause()
public void setOrderClause(String orderClause)
public String getGroupClause()
public void setGroupClause(String groupClause)
public String getHavingClause()
public void setHavingClause(String havingClause)
public int getLimit()
public void setLimit(int limit)
public int getOffset()
public void setOffset(int offset)
public Query.QueryType getType()
public String[] getCanonicalFields(EntityInfo<?,?> entityInfo)
protected <K> String toSQL(EntityInfo<? extends RawEntity<K>,K> entityInfo, DatabaseProvider provider, TableNameConverter converter, boolean count)
protected void setParameters(EntityManager manager, PreparedStatement stmt) throws SQLException
SQLException
public static Query select()
Query
which will select the primary key field of the entity.public static Query select(String fields)
Query
and set the field list in the SELECT
clause.fields
- The fields to select, as comma-delimited field names. Spaces are OK. Must not contain "*"
.IllegalArgumentException
- if fields contains "*"
Copyright © 2007-2017. All Rights Reserved.