AstVisitor, SelectCombiningQueryStep, SelectFinalStep, SelectFromStep, SelectGroupByStep, SelectHavingFirstStep, SelectHavingManySteps, SelectJoinManyStepsStep, SelectJoinOnFirstStep, SelectJoinOnManySteps, SelectJoinStep, SelectLimitStep, SelectLockingManySteps, SelectLockingOfTableStep, SelectLockingStep, SelectLockingWaitingStep, SelectOffsetStep, SelectOrderByStep, SelectWhereFirstStep, SelectWhereManySteps, Querypublic class SelectImpl extends AbstractQuery implements SelectFromStep, SelectJoinStep, SelectJoinOnFirstStep, SelectJoinOnManySteps, SelectWhereManySteps, SelectGroupByStep, SelectHavingFirstStep, SelectHavingManySteps, SelectOrderByStep, SelectLimitStep, SelectOffsetStep, SelectLockingStep, SelectLockingOfTableStep, SelectLockingWaitingStep, SelectLockingManySteps, SelectFinalStep
| Constructor | Description |
|---|---|
SelectImpl(java.lang.String... columnsSelected) |
|
SelectImpl(java.util.List<Expression> names) |
|
SelectImpl(Expression... columnsSelected) |
| Modifier and Type | Method | Description |
|---|---|---|
SelectImpl |
all() |
Clause SELECT ALL ...
|
SelectImpl |
and(Conditions conditions) |
For full information see the
Conditions.and(Conditions) method. |
<T> SelectImpl |
and(T left,
T operator,
T right) |
For full information see the
Conditions.and(Object, Object, Object) method. |
SelectImpl |
andExists(Query query) |
For full information see the
Conditions.andExists(Query) method. |
SelectImpl |
andNot(Conditions conditions) |
For full information see the
Conditions.andNot(Conditions) method. |
<T> SelectImpl |
andNot(T left,
T operator,
T right) |
For full information see the
Conditions.andNot(Object, Object, Object) method. |
SelectImpl |
andNotExists(Query query) |
For full information see the
Conditions.andNotExists(Query) method. |
void |
assemble(AbstractSyntaxTree tree) |
Visits SQL query making a tree from its clauses.
|
SelectImpl |
crossJoin(java.lang.String name) |
|
SelectImpl |
crossJoin(Expression name) |
|
SelectImpl |
distinct() |
Clause SELECT DISTINCT ...
|
SelectImpl |
distinctOn(java.lang.String... columns) |
Clause SELECT DISTINCT ON ( ..
|
SelectImpl |
distinctOn(Expression... columns) |
Clause SELECT DISTINCT ON ( ..
|
SelectImpl |
except(SelectFinalStep select) |
Combine main query with
select query using EXCEPT. |
SelectImpl |
exceptAll(SelectFinalStep select) |
Combine main query with
select query using EXCEPT ALL. |
SelectImpl |
forKeyShare() |
Specifies a locking mode name FOR KEY SHARE.
|
SelectImpl |
forNoKeyUpdate() |
Specifies a locking mode name FOR NO KEY UPDATE.
|
SelectImpl |
forShare() |
Specifies a locking mode name FOR SHARE.
|
SelectImpl |
forUpdate() |
Specifies a locking mode name FOR UPDATE.
|
SelectImpl |
from(java.lang.String... tables) |
Specify table name that be used to retrieve rows.
|
SelectImpl |
from(From... tables) |
Specify table name that be used to retrieve rows.
|
SelectImpl |
from(Expression... tables) |
Specify table name that be used to retrieve rows.
|
SelectImpl |
fullJoin(java.lang.String name) |
|
SelectImpl |
fullJoin(Expression name) |
|
SelectImpl |
groupBy(java.lang.String... expressions) |
|
SelectImpl |
groupBy(Expression... expressions) |
|
SelectImpl |
having(Conditions conditions) |
This function useful in a few case:
When the
conditions is a special case of condition,
like Queryman.conditionBetween(Object, Object, Object), or
Queryman.conditionSome(Object, Object, Query) etc. |
<T> SelectImpl |
having(T left,
T operator,
T right) |
Example:
// SELECT year FROM book HAVING year > 2010
select("year", "id")
.from("book")
.having("year", ">", "2010")
.sql()
|
SelectImpl |
havingExists(Query query) |
Example:
// SELECT * FROM book HAVING EXISTS (SELECT * FROM author)
select("*")
.from("book")
.havingExists(select("*").from("authors"))
.sql()
|
SelectImpl |
innerJoin(java.lang.String name) |
|
SelectImpl |
innerJoin(Expression name) |
|
SelectImpl |
intersect(SelectFinalStep select) |
Combine main query with
select query using INTERSECT. |
SelectImpl |
intersectAll(SelectFinalStep select) |
Combine main query with
select query using INTERSECT ALL. |
SelectImpl |
join(java.lang.String name) |
|
SelectImpl |
join(Expression name) |
|
SelectImpl |
leftJoin(java.lang.String name) |
|
SelectImpl |
leftJoin(Expression name) |
|
SelectImpl |
limit(long limit) |
|
SelectImpl |
limit(Expression limit) |
|
SelectImpl |
naturalJoin(java.lang.String name) |
|
SelectImpl |
naturalJoin(Expression name) |
|
SelectImpl |
noWait() |
Specifies NOWAIT mode, meaning the SELECT statement will report an error,
if rows are locked, rather than will wait for rows.
|
SelectImpl |
of(java.lang.String... tables) |
Specifies tables, rows of those are locking.
|
SelectImpl |
of(Expression... tables) |
Specifies tables, rows of those are locking.
|
SelectImpl |
offset(long offset) |
Specifies the offset start.
|
SelectImpl |
offset(Expression offset) |
Specifies the offset start.
|
SelectImpl |
on(boolean conditions) |
This form of JOIN ON condition is equivalent to CROSS JOIN.
|
SelectImpl |
on(Conditions conditions) |
|
<T> SelectImpl |
on(T left,
T operator,
T right) |
Example:
// SELECT * FROM book AS b JOIN author a ON a.id = b.author_id
select("*")
.from(asName("book").as("b"))
.join("author a")
.on("a.id", "=", "b.author_id")
.sql()
|
SelectImpl |
onExists(Query query) |
|
SelectImpl |
or(Conditions conditions) |
For full information see the
Conditions.or(Conditions) method. |
<T> SelectImpl |
or(T left,
T operator,
T right) |
For full information see the
Conditions.or(Object, Object, Object) method. |
SelectImpl |
orderBy(java.lang.String column) |
Specifies an ordering of output
|
SelectImpl |
orderBy(java.lang.String column,
java.lang.String sorting) |
Specifies an ordering of output
|
SelectImpl |
orderBy(java.lang.String column,
java.lang.String sorting,
java.lang.String nulls) |
Specifies an ordering of output.
|
SelectImpl |
orderBy(OrderBy... ordersBy) |
Specifies an ordering of output.
|
SelectImpl |
orExists(Query query) |
For full information see the
Conditions.orExists(Query) method. |
SelectImpl |
orNot(Conditions conditions) |
For full information see the
Conditions.orNot(Conditions) method. |
<T> SelectImpl |
orNot(T left,
T operator,
T right) |
For full information see the
Conditions.orNot(Object, Object, Object) method. |
SelectImpl |
orNotExists(Query query) |
For full information see the
Conditions.orNot(Conditions) method. |
SelectImpl |
rightJoin(java.lang.String name) |
|
SelectImpl |
rightJoin(Expression name) |
|
SelectImpl |
skipLocked() |
Specifies SKIP LOCKED mode, meaning the SELECT statement will omit the
locked rows.
|
SelectImpl |
union(SelectFinalStep select) |
Combine main query with
select query using UNION. |
SelectImpl |
unionAll(SelectFinalStep select) |
Combine main query with
select query using UNION ALL. |
SelectImpl |
using(java.lang.String... name) |
Example:
// SELECT * FROM book JOIN author USING (id)
select("*")
.from("book")
.join("author")
.using("id")
.sql()
|
SelectImpl |
using(Expression... columns) |
Example:
// SELECT * FROM book JOIN author USING (id)
select("*")
.from(asName("book"))
.join("author")
.using(asName("id"))
.sql()
|
SelectImpl |
where(Conditions conditions) |
This function useful in a few case:
When the
conditions is a special case of condition,
like Queryman.conditionBetween(Object, Object, Object), or
Queryman.conditionSome(Object, Object, Query) etc. |
<T> SelectImpl |
where(T left,
T operator,
T right) |
Example:
// SELECT * FROM book WHERE year > 2010
select("*")
.from("book")
.where("year", ">", "2010")
.sql()
|
SelectImpl |
whereExists(Query query) |
Example:
// SELECT * FROM book WHERE EXISTS (SELECT * FROM author)
select("*")
.from("book")
.whereExists(select("*").from("authors"))
.sql()
|
buildPreparedStatement, sql, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbuildPreparedStatement, sqlpublic SelectImpl(java.lang.String... columnsSelected)
public SelectImpl(java.util.List<Expression> names)
public SelectImpl(Expression... columnsSelected)
public final SelectImpl all()
public final SelectImpl distinct()
public final SelectImpl distinctOn(java.lang.String... columns)
public final SelectImpl distinctOn(Expression... columns)
public final void assemble(AbstractSyntaxTree tree)
AstVisitorassemble in interface AstVisitortree - - abstract syntax treepublic final SelectImpl from(java.lang.String... tables)
SelectFromStepselect("id").from("books as b")
select("id").from("books as b (id, name)")from in interface SelectFromStepSelectFromStep.from(Expression...),
SelectFromStep.from(From...)public final SelectImpl from(Expression... tables)
SelectFromStep
Queryman.asName("books").as("b"); // books AS b
Queryman.asName("books").as("b", "id", "name"); // books AS b(id, name)
from in interface SelectFromStepSelectFromStep.from(String...),
SelectFromStep.from(From...),
Expressionpublic final SelectImpl from(From... tables)
SelectFromStep
Queryman.from("books").as("b"); // books AS b
Queryman.from("books").as("b", "id", "name"); // books AS b(id, name)
Queryman.fromOnly("books"); // ONLY books
from in interface SelectFromStepSelectFromStep.from(Expression...),
SelectFromStep.from(String...),
Queryman.from(String),
Queryman.from(Expression),
Queryman.fromOnly(String),
Queryman.fromOnly(Expression)public final <T> SelectImpl where(T left, T operator, T right)
SelectWhereFirstStep
// SELECT * FROM book WHERE year > 2010
select("*")
.from("book")
.where("year", ">", "2010")
.sql()
where in interface SelectWhereFirstStepT - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandpublic final SelectImpl where(Conditions conditions)
SelectWhereFirstStepconditions is a special case of condition,
like Queryman.conditionBetween(Object, Object, Object), or
Queryman.conditionSome(Object, Object, Query) etc.
See the first example.
conditions is a group of conditions are joined by AND, AND NOT,
OR and OR NOT operators. These conditions are being a grouped condition,
and will be surrounded by parentheses.
See the second example.
// SELECT * FROM book WHERE id BETWEEN 1 AND 10
select("*")
.from("book")
.where(conditionBetween("id", "1", "10"))
.sql()
The second example:
// SELECT * FROM book WHERE (id BETWEEN 1 AND 10 AND name = 'Advanced SQL')
select("*")
.from("book")
.where(
conditionBetween("id", "1", "10")
.and(asName("name"), operator("="), asString("Advanced SQL"))
)
.sql()
where in interface SelectWhereFirstStepconditions - conditionQueryman.condition(Object, Object, Object)public final SelectImpl whereExists(Query query)
SelectWhereFirstStep
// SELECT * FROM book WHERE EXISTS (SELECT * FROM author)
select("*")
.from("book")
.whereExists(select("*").from("authors"))
.sql()
whereExists in interface SelectWhereFirstStepquery - subquerypublic final <T> SelectImpl and(T left, T operator, T right)
SelectJoinOnManyStepsConditions.and(Object, Object, Object) method.and in interface SelectHavingManyStepsand in interface SelectJoinOnManyStepsand in interface SelectWhereManyStepsT - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandpublic final SelectImpl and(Conditions conditions)
SelectJoinOnManyStepsConditions.and(Conditions) method.and in interface SelectHavingManyStepsand in interface SelectJoinOnManyStepsand in interface SelectWhereManyStepsconditions - conditionspublic final SelectImpl andExists(Query query)
SelectJoinOnManyStepsConditions.andExists(Query) method.andExists in interface SelectHavingManyStepsandExists in interface SelectJoinOnManyStepsandExists in interface SelectWhereManyStepsquery - subquerypublic final <T> SelectImpl andNot(T left, T operator, T right)
SelectJoinOnManyStepsConditions.andNot(Object, Object, Object) method.andNot in interface SelectHavingManyStepsandNot in interface SelectJoinOnManyStepsandNot in interface SelectWhereManyStepsT - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandpublic final SelectImpl andNot(Conditions conditions)
SelectJoinOnManyStepsConditions.andNot(Conditions) method.andNot in interface SelectHavingManyStepsandNot in interface SelectJoinOnManyStepsandNot in interface SelectWhereManyStepsconditions - conditionspublic final SelectImpl andNotExists(Query query)
SelectJoinOnManyStepsConditions.andNotExists(Query) method.andNotExists in interface SelectHavingManyStepsandNotExists in interface SelectJoinOnManyStepsandNotExists in interface SelectWhereManyStepsquery - subquerypublic final <T> SelectImpl or(T left, T operator, T right)
SelectJoinOnManyStepsConditions.or(Object, Object, Object) method.or in interface SelectHavingManyStepsor in interface SelectJoinOnManyStepsor in interface SelectWhereManyStepsT - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandpublic final SelectImpl or(Conditions conditions)
SelectJoinOnManyStepsConditions.or(Conditions) method.or in interface SelectHavingManyStepsor in interface SelectJoinOnManyStepsor in interface SelectWhereManyStepsconditions - conditionspublic final SelectImpl orExists(Query query)
SelectJoinOnManyStepsConditions.orExists(Query) method.orExists in interface SelectHavingManyStepsorExists in interface SelectJoinOnManyStepsorExists in interface SelectWhereManyStepsquery - subquerypublic final <T> SelectImpl orNot(T left, T operator, T right)
SelectJoinOnManyStepsConditions.orNot(Object, Object, Object) method.orNot in interface SelectHavingManyStepsorNot in interface SelectJoinOnManyStepsorNot in interface SelectWhereManyStepsT - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandpublic final SelectImpl orNot(Conditions conditions)
SelectJoinOnManyStepsConditions.orNot(Conditions) method.orNot in interface SelectHavingManyStepsorNot in interface SelectJoinOnManyStepsorNot in interface SelectWhereManyStepsconditions - conditionspublic final SelectImpl orNotExists(Query query)
SelectJoinOnManyStepsConditions.orNot(Conditions) method.orNotExists in interface SelectHavingManyStepsorNotExists in interface SelectJoinOnManyStepsorNotExists in interface SelectWhereManyStepsquery - subquerypublic final SelectImpl groupBy(java.lang.String... expressions)
groupBy in interface SelectGroupBySteppublic final SelectImpl groupBy(Expression... expressions)
groupBy in interface SelectGroupBySteppublic final SelectImpl orderBy(java.lang.String column)
SelectOrderBySteporderBy in interface SelectOrderByStepcolumn - column name or expressionpublic final SelectImpl orderBy(java.lang.String column, java.lang.String sorting)
SelectOrderBySteporderBy in interface SelectOrderByStepcolumn - column name or expressionsorting - sorting constant: ASC | DESC | USING constantpublic final SelectImpl orderBy(java.lang.String column, java.lang.String sorting, java.lang.String nulls)
SelectOrderBySteporderBy in interface SelectOrderByStepcolumn - column name or expressionsorting - sorting constant: ASC | DESC | USING constantnulls - sets a position a row with null values for name column.
It may be FIRST | LASTpublic final SelectImpl orderBy(OrderBy... ordersBy)
SelectOrderBySteporderBy in interface SelectOrderByStepordersBy - list of OrderBy objects.Queryman.orderBy(String)public final SelectImpl limit(long limit)
limit in interface SelectLimitSteppublic final SelectImpl limit(Expression limit)
limit in interface SelectLimitSteppublic final SelectImpl offset(long offset)
SelectOffsetStepoffset in interface SelectOffsetStepoffset - offset startSelectOffsetStep.offset(Expression)public final SelectImpl offset(Expression offset)
SelectOffsetStepoffset in interface SelectOffsetStepoffset - offset startpublic final SelectImpl join(java.lang.String name)
join in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionSelectJoinStep.join(Expression)public final SelectImpl join(Expression name)
join in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionpublic final SelectImpl innerJoin(java.lang.String name)
innerJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionSelectJoinStep.innerJoin(Expression)public final SelectImpl innerJoin(Expression name)
innerJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionpublic final SelectImpl leftJoin(java.lang.String name)
leftJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionSelectJoinStep.leftJoin(Expression)public final SelectImpl leftJoin(Expression name)
leftJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionpublic final SelectImpl rightJoin(java.lang.String name)
rightJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionSelectJoinStep.rightJoin(Expression)public final SelectImpl rightJoin(Expression name)
rightJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionpublic final SelectImpl fullJoin(java.lang.String name)
fullJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionSelectJoinStep.fullJoin(Expression)public final SelectImpl fullJoin(Expression name)
fullJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionpublic final SelectImpl crossJoin(java.lang.String name)
crossJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionSelectJoinStep.crossJoin(Expression)public final SelectImpl crossJoin(Expression name)
crossJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionpublic final SelectImpl naturalJoin(java.lang.String name)
naturalJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionSelectJoinStep.naturalJoin(Expression)public final SelectImpl naturalJoin(Expression name)
naturalJoin in interface SelectJoinStepname - is a table name. actually it can be ROW,
or VALUES expressionpublic final SelectImpl using(java.lang.String... name)
SelectJoinOnFirstStep
// SELECT * FROM book JOIN author USING (id)
select("*")
.from("book")
.join("author")
.using("id")
.sql()
using in interface SelectJoinOnFirstSteppublic final SelectImpl using(Expression... columns)
SelectJoinOnFirstStep
// SELECT * FROM book JOIN author USING (id)
select("*")
.from(asName("book"))
.join("author")
.using(asName("id"))
.sql()
using in interface SelectJoinOnFirstSteppublic final SelectImpl on(boolean conditions)
SelectJoinOnFirstStep
// SELECT * FROM book AS b JOIN author a ON (true)
select("*")
.from(asName("book").as("b"))
.join("author a")
.on(true)
.sql()
on in interface SelectJoinOnFirstSteppublic final <T> SelectImpl on(T left, T operator, T right)
SelectJoinOnFirstStep
// SELECT * FROM book AS b JOIN author a ON a.id = b.author_id
select("*")
.from(asName("book").as("b"))
.join("author a")
.on("a.id", "=", "b.author_id")
.sql()
on in interface SelectJoinOnFirstStepT - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandpublic final SelectImpl on(Conditions conditions)
on in interface SelectJoinOnFirstSteppublic final SelectImpl onExists(Query query)
onExists in interface SelectJoinOnFirstSteppublic final SelectImpl union(SelectFinalStep select)
SelectCombiningQueryStepselect query using UNION.union in interface SelectCombiningQuerySteppublic final SelectImpl unionAll(SelectFinalStep select)
SelectCombiningQueryStepselect query using UNION ALL.unionAll in interface SelectCombiningQuerySteppublic final SelectImpl intersect(SelectFinalStep select)
SelectCombiningQueryStepselect query using INTERSECT.intersect in interface SelectCombiningQuerySteppublic final SelectImpl intersectAll(SelectFinalStep select)
SelectCombiningQueryStepselect query using INTERSECT ALL.intersectAll in interface SelectCombiningQuerySteppublic final SelectImpl except(SelectFinalStep select)
SelectCombiningQueryStepselect query using EXCEPT.except in interface SelectCombiningQuerySteppublic final SelectImpl exceptAll(SelectFinalStep select)
SelectCombiningQueryStepselect query using EXCEPT ALL.exceptAll in interface SelectCombiningQuerySteppublic final <T> SelectImpl having(T left, T operator, T right)
SelectHavingFirstStep
// SELECT year FROM book HAVING year > 2010
select("year", "id")
.from("book")
.having("year", ">", "2010")
.sql()
having in interface SelectHavingFirstStepT - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandpublic final SelectImpl having(Conditions conditions)
SelectHavingFirstStepconditions is a special case of condition,
like Queryman.conditionBetween(Object, Object, Object), or
Queryman.conditionSome(Object, Object, Query) etc.
See the first example.
conditions is a group of conditions are joined by AND, AND NOT,
OR and OR NOT operators. These conditions are being a grouped condition,
and will be surrounded by parentheses.
See the second example.
// SELECT id FROM book HAVING id BETWEEN 1 AND 10
select("id")
.from("book")
.having(conditionBetween("id", "1", "10"))
.sql()
The second example:
// SELECT id, name FROM book HAVING (id BETWEEN 1 AND 10 AND name = 'Advanced SQL')
select("id", "name")
.from("book")
.having(
conditionBetween("id", "1", "10")
.and(asName("name"), operator("="), asString("Advanced SQL"))
)
.sql()
having in interface SelectHavingFirstStepconditions - conditionQueryman.condition(Object, Object, Object)public final SelectImpl havingExists(Query query)
SelectHavingFirstStep
// SELECT * FROM book HAVING EXISTS (SELECT * FROM author)
select("*")
.from("book")
.havingExists(select("*").from("authors"))
.sql()
havingExists in interface SelectHavingFirstStepquery - subquerypublic final SelectImpl forUpdate()
SelectLockingStepforUpdate in interface SelectLockingSteppublic final SelectImpl forNoKeyUpdate()
SelectLockingStepforNoKeyUpdate in interface SelectLockingSteppublic final SelectImpl forShare()
SelectLockingStepforShare in interface SelectLockingSteppublic final SelectImpl forKeyShare()
SelectLockingStepforKeyShare in interface SelectLockingSteppublic final SelectImpl of(java.lang.String... tables)
SelectLockingOfTableStepof in interface SelectLockingOfTableSteptables - list of tablesSelectLockingOfTableStep.of(Expression...)public final SelectImpl of(Expression... tables)
SelectLockingOfTableStepof in interface SelectLockingOfTableSteptables - list of tablespublic final SelectImpl skipLocked()
SelectLockingWaitingStepskipLocked in interface SelectLockingWaitingSteppublic final SelectImpl noWait()
SelectLockingWaitingStepnoWait in interface SelectLockingWaitingStep