public class Query extends DmlBase
DmlBase.PathCondition| Modifier and Type | Field and Description |
|---|---|
static String |
FIRST_RESULT |
static String |
LAST_RESULT |
cachedAssociation, condition, db, discriminatorConditions, JOIN_PREFIX, joinBag, joins, lastFkAlias, lastJoin, parameters, path, PREFIX, rawSql, simpleJdbc, table, tableAlias| Constructor and Description |
|---|
Query(AbstractDb db,
Table table) |
Query(Query subquery) |
| Modifier and Type | Method and Description |
|---|---|
void |
alias(String alias) |
Query |
all() |
Query |
as(String alias)
Defines the alias of the last column, or if none was defined, defines the table alias;
|
Query |
asc()
Define a direção ASCENDENTE da ordem a aplicar na ultima ordem definida
|
Query |
asc(boolean dir)
Define a direção da ordem a aplicar na ultima ordem definida
|
Query |
asc(Column<?> column) |
Query |
asc(Column<?> column,
String alias) |
Query |
asc(String column) |
Query |
ascBy(Column<?> column) |
Query |
column(Object... cols) |
void |
copy(Query other) |
Query |
count() |
Query |
count(Object... expr) |
Query |
desc()
Define a direção DESCENDENTE da ordem a aplicar na ultima ordem definida
|
Query |
desc(Column<?> column) |
Query |
desc(Column<?> column,
String alias) |
Query |
desc(String column) |
Query |
descBy(Column<?> column) |
Query |
distinct() |
Query |
exclude(Column<?>... columns)
includes all column from the table from the last association but the ones declared in this method.
|
Query |
fetch()
This will trigger a result that can be dumped in a tree object
using current association path to build the tree result.
If no columns where included in this path, it will includes all the columns of all the tables referred by the association path. |
String |
getAlias() |
List<Function> |
getColumns() |
int[] |
getGroupBy() |
List<Group> |
getGroupByFunction() |
Condition |
getHaving() |
int |
getLimit() |
List<Order> |
getOrders() |
int |
getSkip() |
RawSql |
getSql()
SQL String.
|
Query |
getSubquery() |
List<Union> |
getUnions() |
Query |
groupBy(Column<?>... cols) |
Query |
groupBy(int... pos) |
Query |
groupBy(String... aliases) |
Query |
groupByUntil(int untilPos) |
Query |
having(Condition... having)
Adds a Having clause to the query.
|
Query |
include(Object... columns)
Includes any kind of column (table column or function)
referring to the table targeted by the last association.
|
Query |
inner(Association... associations)
includes the associations as inner joins to the current path.
|
Query |
innerFetch(Association... associations)
Executa um INNER join com as tabelas definidas pelas foreign keys.
TODAS as colunas das tabelas intermédias são incluidas no select bem como TODAS as colunas da tabela no fim das associações. |
Query |
innerJoin(Association... associations)
The same as inner(...).join()
|
boolean |
isDistinct() |
boolean |
isFlat() |
Query |
join()
This will NOT trigger a result that can be dumped in a tree object.
Any included column, will be considered as belonging to the root object. |
Query |
limit(int maxResults) |
<T> List<T> |
list(Class<T> klass)
Executes a query and transform the results to the bean type passed as
parameter,
matching the alias with bean property name. |
<T> List<T> |
list(Class<T> klass,
boolean reuse)
Executes a query and transform the results to the bean type,
matching the alias with bean property name. |
<T> List<T> |
list(IQueryRowTransformer<T> transformer) |
<T> List<T> |
list(IRowTransformer<T> rowMapper)
Executes a query and transform the results according to the transformer
|
List<Object[]> |
listRaw(Class<?>... clazzes) |
<T> List<T> |
listRaw(Class<T> clazz)
Retrives a collection of objects of simple type (not beans).
|
Query |
on(Condition... condition)
Restriction to apply to the previous association
|
Query |
order(Column<?> column)
Order by a column belonging to the driving table
If you want to order by a column from the table targeted by the last association, use orderBy |
Query |
order(Column<?> column,
Association... associations)
Order by column belonging to another table.
|
Query |
order(Column<?> column,
String alias) |
Query |
order(String column) |
Query |
orderBy(Column<?> column)
Define a coluna a ordenar.
|
Query |
outer(Association... associations)
includes the associations as outer joins to the current path
|
Query |
outerFetch(Association... associations)
Executa um OUTER join com as tabelas definidas pelas foreign keys.
TODAS as colunas das tabelas intermédias são incluidas no select bem como a TODAS as colunas da tabela no fim das associações. |
Query |
outerJoin(Association... associations)
The same as outer(...).join()
|
void |
run(IProcessor processor)
Every row will be processed by the only method of the supplied object.
The Object type for each column is obtained from the types of the method parameters. The processed rows are not collected, so any returning object is discarded. |
void |
runFirst(IProcessor processor) |
void |
runOne(IProcessor processor) |
<T> T |
select(Class<T> klass) |
<T> T |
select(Class<T> klass,
boolean reuse) |
<T> T |
select(IRowTransformer<T> rowMapper) |
Query |
skip(int firstResult) |
Function |
subQuery() |
Query |
union(Query query) |
Query |
unionAll(Query query) |
<T> T |
unique(Class<T> klass) |
<T> T |
unique(IRowTransformer<T> rowMapper)
Executes a query and transform the results according to the transformer.
If more than one result is returned an Exception will occur. |
BigDecimal |
uniqueBigDecimal() |
Boolean |
uniqueBoolean() |
Double |
uniqueDouble() |
Float |
uniqueFloat() |
Integer |
uniqueInteger() |
Long |
uniqueLong() |
Object[] |
uniqueRaw(Class<?>... clazzes) |
<T> T |
uniqueRaw(Class<T> clazz) |
String |
uniqueString() |
Query |
where(Condition... restrictions) |
Query |
where(Condition restriction) |
Query |
where(List<Condition> restrictions) |
addJoin, applyInclude, applyOn, applyWhere, callerName, connection, debug, debugSQL, debugTime, deepestCommonPath, driver, dumpParameters, getAliasForAssociation, getCondition, getDb, getJoins, getParameter, getParameters, getSimpleJdbc, getTable, getTableAlias, joinTo, nextRawIndex, replaceRaw, setParameter, setParameter, setTableAliaspublic static final String FIRST_RESULT
public static final String LAST_RESULT
public Query(AbstractDb db, Table table)
public Query(Query subquery)
public String getAlias()
public boolean isFlat()
public void alias(String alias)
public void copy(Query other)
public int getSkip()
public Query skip(int firstResult)
public int getLimit()
public Query limit(int maxResults)
public Query getSubquery()
public Query distinct()
public boolean isDistinct()
public Query all()
public Query count()
public Query as(String alias)
alias - The Aliaspublic Query order(Column<?> column)
column - public Query order(Column<?> column, Association... associations)
column - a coluna de ordenaçãoassociations - associações para chegar à tabela que contem a coluna de
ordenaçãopublic Query orderBy(Column<?> column)
column - public Query asc()
public Query asc(boolean dir)
dir - public Query desc()
public Query inner(Association... associations)
associations - public Query outer(Association... associations)
associations - public Query fetch()
public Query join()
public Query innerJoin(Association... associations)
associations - public Query outerJoin(Association... associations)
associations - public Query include(Object... columns)
columns - or functionspublic Query exclude(Column<?>... columns)
columns - public Query outerFetch(Association... associations)
associations - as foreign keys que definem uma navegaçãopublic Query innerFetch(Association... associations)
associations - as foreign keys que definem uma navegaçãopublic Query on(Condition... condition)
condition - Restrictionpublic Query groupByUntil(int untilPos)
public Query groupBy(int... pos)
public int[] getGroupBy()
public Condition getHaving()
public Query having(Condition... having)
having - public void run(IProcessor processor)
processor - A processor object that must have one declared method and this method must at least one parameter.public void runOne(IProcessor processor)
public void runFirst(IProcessor processor)
public <T> List<T> listRaw(Class<T> clazz)
clazz - class of the object to returnpublic <T> T uniqueRaw(Class<T> clazz)
public Boolean uniqueBoolean()
public Integer uniqueInteger()
public Long uniqueLong()
public Float uniqueFloat()
public Double uniqueDouble()
public String uniqueString()
public BigDecimal uniqueBigDecimal()
public <T> List<T> list(Class<T> klass, boolean reuse)
T - the bean typeklass - The bean typereuse - Indicates if for the same entity, a new bean should be
created, or reused a previous instanciated one.public <T> List<T> list(Class<T> klass)
klass - public <T> List<T> list(IQueryRowTransformer<T> transformer)
public <T> List<T> list(IRowTransformer<T> rowMapper)
T - the bean typerowMapper - The row transformerpublic <T> T unique(IRowTransformer<T> rowMapper)
T - the bean typerowMapper - The row transformerpublic <T> T unique(Class<T> klass)
public <T> T select(Class<T> klass)
public <T> T select(Class<T> klass, boolean reuse)
public <T> T select(IRowTransformer<T> rowMapper)
public RawSql getSql()
public Function subQuery()
Copyright © 2019. All rights reserved.