T
- The target type of the query.public interface SelectQuery<T> extends BaseQuery<T>, QueryCondition
SelectQuery is the main interface for build a "SELECT" query, it allow to add projection, condition, order and having clauses using instances of domain classes.
SelectQuery<Person> query = new GenericSelectQuery<Person>(Person.class);
Person toSearch = query.target();
query.prj(toSearch.getName());
query.eq(toSearch.getMum().getName(),"elisabeth");
query.gt(toSearch.getAge(),20);
query.order(toSearch.getName());
Modifier and Type | Method and Description |
---|---|
HavingCondition |
having(Object projection,
ProjectionType type)
Declare an having condition on projection.
|
<J> J |
join(Class<J> joinClass)
Create a join object with the specified type
Example:
SelectQuery<Person> query = ... |
<J> J |
join(Class<J> joinClass,
JoinType type)
Create a join object with the specified type and specific join operator
Example:
SelectQuery<Person> query = ... |
<J> J |
join(J joinPath,
Class<J> joinClass)
Create a join object with the specified type, on the specified base path
Example:
SelectQuery<Person> query = ... |
<J> J |
join(J joinPath,
Class<J> joinClass,
JoinType type)
Create a join object with the specified type, on the specified base path
and join operator
Example:
SelectQuery<Person> query = ... |
void |
order(Object order)
Add an order condition to query.
|
void |
order(Object order,
OrderType type)
Add an order to query.
|
void |
order(Object order,
ProjectionType projectionType,
OrderType type)
Add an order to query.
|
void |
prj(Object projection)
Add a projection to query.
|
void |
prj(Object projection,
ProjectionType type)
Add a projection to query with an operator.
|
<S> SelectQuery<S> |
subQuery(Class<S> target)
Create a new Sub Query of current query.
|
void prj(Object projection)
SelectQuery<Person> query = ....
query.prj(query.target().getName());
projection
- the projection object to add.void prj(Object projection, ProjectionType type)
SelectQuery<Person> query = ....
query.prj(query.target().getSurname(),ProjectionType.COUNT);
projection
- the projection object to add.type
- the type of projection to add.void order(Object order)
SelectQuery<Person> query = ....
query.order(query.target().getName());
order
- the order to add.void order(Object order, OrderType type)
SelectQuery<Person> query = ....
query.order(query.target().getName(),OrderType.DESC);
order
- the order to add.type
- the type of order.void order(Object order, ProjectionType projectionType, OrderType type)
SelectQuery<Person> query = ....
query.order(query.target().getSurname(),ProjectionType.COUNT,OrderType.DESC);
order
- the order to add.projectionType
- the tipe of projection for grouping actions in order.type
- the type of order.HavingCondition having(Object projection, ProjectionType type)
SelectQuery<Person> query = ....
query.having(query.target().getSurname(),ProjectionType.COUNT).gt(20);
projection
- target of condition.type
- grouping operation<S> SelectQuery<S> subQuery(Class<S> target)
SelectQuery<:Person> query = ....
SelectQuery<Home> queryHomes = query.subQuery(Home.class);
....
query.in(query.target().getHome(),queryHomes);
target
- class target of sub query.<J> J join(Class<J> joinClass)
SelectQuery<Person> query = ...
Home home = query.join(Home.class);
query.eq(query.target().getAddress(),home.getAddress());
joinClass
- the type of the join object.<J> J join(Class<J> joinClass, JoinType type)
SelectQuery<Person> query = ...
Home home = query.join(Home.class,JoinType.LEFT);
query.eq(query.target().getAddress(),home.getAddress());
joinClass
- the type of the join object.type
- the join operator type.<J> J join(J joinPath, Class<J> joinClass)
SelectQuery<Person> query = ...
Company company = query.join(target.getCompany(),Company.class);
query.eq(query.target().getAddress(),company.getAddress());
joinPath
- the path to reach the base object.joinClass
- the type of the join object.<J> J join(J joinPath, Class<J> joinClass, JoinType type)
SelectQuery<Person> query = ...
Company company = query.join(target.getCompany(),Company.class,JoinType.LEFT);
query.eq(query.target().getAddress(),company.getAddress());
joinPath
- the path to reach the base object.joinClass
- the type of the join object.type
- the join operator type.Copyright © 2014 Object Query. All rights reserved.