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 aQuery
and set the field list in theSELECT
clause. -
Method Summary
Modifier and TypeMethodDescriptiondistinct()
String[]
getCanonicalFields
(EntityInfo<?, ?> entityInfo) getJoins()
int
getLimit()
int
protected Query.FieldMetadata
getSingleFieldMetadata
(String field) getTable()
getType()
Object[]
boolean
limit
(int limit) offset
(int offset) static Query
select()
Create aQuery
which will select the primary key field of the entity.static Query
Create aQuery
and set the field list in theSELECT
clause.void
setDistinct
(boolean distinct) void
setGroupClause
(String groupClause) void
setHavingClause
(String havingClause) void
void
setLimit
(int limit) void
setOffset
(int offset) void
setOrderClause
(String orderClause) protected void
setParameters
(EntityManager manager, PreparedStatement stmt) void
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)
-
Field Details
-
ALIAS_PATTERN
-
AGGREGATE_FUNCTION_PATTERN
-
-
Constructor Details
-
Query
Create aQuery
and set the field list in theSELECT
clause.- 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 aQuery
which will select the primary key field of the entity.- Returns:
- non-null Query
-
select
Create aQuery
and set the field list in theSELECT
clause.- 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"*"
-