Package net.java.ao
Class Query
java.lang.Object
net.java.ao.Query
- All Implemented Interfaces:
Serializable
A cross-database representation of a SELECT query, independent of database provider type.
Use with DatabaseProvider.renderQuery(Query, net.java.ao.schema.TableNameConverter, boolean)
to produce the database-specific SQL.
- Author:
- Daniel Spiewak
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionQuery(Query.QueryType type, String fields) Create aQueryand set the field list in theSELECTclause. -
Method Summary
Modifier and TypeMethodDescriptiondistinct()String[]getCanonicalFields(EntityInfo<?, ?> entityInfo) getJoins()intgetLimit()intprotected Query.FieldMetadatagetSingleFieldMetadata(String field) getTable()getType()Object[]booleanlimit(int limit) offset(int offset) static Queryselect()Create aQuerywhich will select the primary key field of the entity.static QueryCreate aQueryand set the field list in theSELECTclause.voidsetDistinct(boolean distinct) voidsetGroupClause(String groupClause) voidsetHavingClause(String havingClause) voidvoidsetLimit(int limit) voidsetOffset(int offset) voidsetOrderClause(String orderClause) protected voidsetParameters(EntityManager manager, PreparedStatement stmt) voidvoidsetTableType(Class<? extends RawEntity<?>> tableType) voidsetWhereClause(String whereClause) voidsetWhereParams(Object[] whereParams) protected <K> StringtoSQL(EntityInfo<? extends RawEntity<K>, K> entityInfo, DatabaseProvider provider, TableNameConverter converter, boolean count)
-
Field Details
-
ALIAS_PATTERN
-
AGGREGATE_FUNCTION_PATTERN
-
-
Constructor Details
-
Query
Create aQueryand set the field list in theSELECTclause.- Parameters:
fields- The fields to select, as comma-delimited field names. Spaces are OK. Must not contain"*".- Throws:
IllegalArgumentException- if fields contains"*"
-
-
Method Details
-
getFields
-
getFieldMetadata
-
distinct
-
from
-
from
-
where
-
order
-
group
-
having
-
limit
-
offset
-
alias
-
getAlias
-
join
-
join
-
isDistinct
public boolean isDistinct() -
setDistinct
public void setDistinct(boolean distinct) -
getTableType
-
setTableType
-
getTable
-
setTable
-
getWhereClause
-
setWhereClause
-
getWhereParams
-
setWhereParams
-
getOrderClause
-
setOrderClause
-
getGroupClause
-
setGroupClause
-
getHavingClause
-
setHavingClause
-
getLimit
public int getLimit() -
setLimit
public void setLimit(int limit) -
getOffset
public int getOffset() -
setOffset
public void setOffset(int offset) -
getJoins
-
setJoins
-
getType
-
getCanonicalFields
-
getAlias
-
getSingleFieldMetadata
-
toSQL
protected <K> String toSQL(EntityInfo<? extends RawEntity<K>, K> entityInfo, DatabaseProvider provider, TableNameConverter converter, boolean count) -
setParameters
- Throws:
SQLException
-
select
Create aQuerywhich will select the primary key field of the entity.- Returns:
- non-null Query
-
select
Create aQueryand set the field list in theSELECTclause.- Parameters:
fields- The fields to select, as comma-delimited field names. Spaces are OK. Must not contain"*".- Returns:
- non-null Query
- Throws:
IllegalArgumentException- if fields contains"*"
-