AstVisitorConditionsImplpublic interface Conditions extends AstVisitor
Expression
object. And operator is being Operator object. For convenience sake
it's possible to use a String representation of them, which will
convert into needful type.
Example:
Queryman.conditions("id", "=", "1")
.and("name", "=", "Alan")
.and(condition("age", ">", "29")
.and("gender", "!=", "male")
.or("code", "=", "3")
);
// "id" = 1 AND (users.name = 'Alan' AND gender != 'male' OR code = 3)
Queryman.conditions(asQuotedName("id"), operator("="), asNumber("1"))
.and(asName("users.name"), "=", asString("Alan")
.and(asName("gender"), "!=", asString("male"))
.or(asName("code"), "=", asNumber("3"))
);
Queryman:| Modifier and Type | Method | Description |
|---|---|---|
Conditions |
and(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> Conditions |
and(T left,
T operator,
T right) |
Example:
// SELECT * FROM book WHERE year > 2010 AND "id" = 1
select("*")
.from("book")
.where("year", ">", "2010")
.and(asQuotedName("id"), operator("="), asNumber(1))
.sql()
|
Conditions |
andExists(Query query) |
Example:
// SELECT * FROM book WHERE year > 2010 AND EXISTS (SELECT * FROM author)
select("*")
.from("book")
.where("year", ">", "2010")
.andExists(select("*").from("authors"))
.sql()
|
Conditions |
andNot(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> Conditions |
andNot(T left,
T operator,
T right) |
Example:
// SELECT * FROM book WHERE year > 2010 AND NOT "id" = 1
select("*")
.from("book")
.where("year", ">", "2010")
.andNot(asQuotedName("id"), operator("="), asNumber(1))
.sql()
|
Conditions |
andNotExists(Query query) |
Example:
// SELECT * FROM book WHERE year > 2010 AND NOT EXISTS (SELECT * FROM author)
select("*")
.from("book")
.where("year", ">", "2010")
.andNotExists(select("*").from("authors"))
.sql()
|
Node |
getNode() |
|
Conditions |
or(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> Conditions |
or(T left,
T operator,
T right) |
Example:
// SELECT * FROM book WHERE year > 2010 OR id = 1
select("*")
.from("book")
.where("year", ">", "2010")
.or("id", "=", "1")
.sql()
|
Conditions |
orExists(Query query) |
Example:
// SELECT * FROM book WHERE year > 2010 OR EXISTS (SELECT * FROM author)
select("*")
.from("book")
.where("year", ">", "2010")
.orExists(select("*").from("authors"))
.sql()
|
Conditions |
orNot(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> Conditions |
orNot(T left,
T operator,
T right) |
Example:
// SELECT * FROM book WHERE year > 2010 OR NOT "id" = 1
select("*")
.from("book")
.where("year", ">", "2010")
.orNot(asQuotedName("id"), "=", 1)
.sql()
|
Conditions |
orNotExists(Query query) |
Example:
// SELECT * FROM book WHERE year > 2010 OR NOT EXISTS (SELECT * FROM author)
select("*")
.from("book")
.where("year", ">", "2010")
.orNotExists(select("*").from("authors"))
.sql()
|
assemble<T> Conditions and(T left, T operator, T right)
// SELECT * FROM book WHERE year > 2010 AND "id" = 1
select("*")
.from("book")
.where("year", ">", "2010")
.and(asQuotedName("id"), operator("="), asNumber(1))
.sql()
T - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandConditions andExists(Query query)
// SELECT * FROM book WHERE year > 2010 AND EXISTS (SELECT * FROM author)
select("*")
.from("book")
.where("year", ">", "2010")
.andExists(select("*").from("authors"))
.sql()
query - subqueryConditions and(Conditions conditions)
conditions 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 conditions are joined by AND, AND NOT,
OR and OR NOT operators. These conditions is being a grouped condition,
and will be surrounded by parentheses.
See the second example.
// SELECT * FROM book WHERE year > 2010 AND id BETWEEN 1 AND 10
select("*")
.from("book")
.where("year", ">", "2010")
.and(conditionBetween("id", "1", "10"))
.sql()
The second example:
// SELECT * FROM book WHERE year > 2010 AND (id BETWEEN 1 AND 10 AND name = 'Advanced SQL')
select("*")
.from("book")
.where("year", ">", "2010")
.and(
conditionBetween("id", "1", "10")
.and(asName("name"), operator("="), asString("Advanced SQL"))
)
.sql()
conditions - conditionQueryman.condition(Object, Object, Object)<T> Conditions andNot(T left, T operator, T right)
// SELECT * FROM book WHERE year > 2010 AND NOT "id" = 1
select("*")
.from("book")
.where("year", ">", "2010")
.andNot(asQuotedName("id"), operator("="), asNumber(1))
.sql()
T - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandConditions andNotExists(Query query)
// SELECT * FROM book WHERE year > 2010 AND NOT EXISTS (SELECT * FROM author)
select("*")
.from("book")
.where("year", ">", "2010")
.andNotExists(select("*").from("authors"))
.sql()
query - subqueryConditions andNot(Conditions conditions)
conditions 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 conditions are joined by AND, AND NOT,
OR and OR NOT operators. These conditions is being a grouped condition,
and will be surrounded by parentheses.
See the second example.
// SELECT * FROM book WHERE year > 2010 AND NOT id BETWEEN 1 AND 10
select("*")
.from("book")
.where("year", ">", "2010")
.andNot(conditionBetween("id", "1", "10"))
.sql()
The second example:
// SELECT * FROM book WHERE year > 2010 AND NOT (id BETWEEN 1 AND 10 AND name = 'Advanced SQL')
select("*")
.from("book")
.where("year", ">", "2010")
.andNot(
conditionBetween("id", "1", "10")
..and(asName("name"), operator("="), asString("Advanced SQL"))
)
.sql()
conditions - conditionQueryman.condition(Object, Object, Object)<T> Conditions or(T left, T operator, T right)
// SELECT * FROM book WHERE year > 2010 OR id = 1
select("*")
.from("book")
.where("year", ">", "2010")
.or("id", "=", "1")
.sql()
T - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandConditions orExists(Query query)
// SELECT * FROM book WHERE year > 2010 OR EXISTS (SELECT * FROM author)
select("*")
.from("book")
.where("year", ">", "2010")
.orExists(select("*").from("authors"))
.sql()
query - subqueryConditions or(Conditions conditions)
conditions 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 conditions are joined by AND, AND NOT,
OR and OR NOT operators. These conditions is being a grouped condition,
and will be surrounded by parentheses.
See the second example.
// SELECT * FROM book WHERE year > 2010 OR id BETWEEN 1 AND 10
select("*")
.from("book")
.where("year", ">", "2010")
.or(conditionBetween("id", "1", "10"))
.sql()
The second example:
// SELECT * FROM book WHERE year > 2010 OR (id BETWEEN 1 AND 10 AND name = 'Advanced SQL')
select("*")
.from("book")
.where("year", ">", "2010")
.ir(
conditionBetween("id", "1", "10")
..and(asName("name"), operator("="), asString("Advanced SQL"))
)
.sql()
conditions - conditionQueryman.condition(Object, Object, Object)<T> Conditions orNot(T left, T operator, T right)
// SELECT * FROM book WHERE year > 2010 OR NOT "id" = 1
select("*")
.from("book")
.where("year", ">", "2010")
.orNot(asQuotedName("id"), "=", 1)
.sql()
T - String, Expression, Operator or Query objectleft - left operandoperator - operatorright - right operandConditions orNotExists(Query query)
// SELECT * FROM book WHERE year > 2010 OR NOT EXISTS (SELECT * FROM author)
select("*")
.from("book")
.where("year", ">", "2010")
.orNotExists(select("*").from("authors"))
.sql()
query - subqueryConditions orNot(Conditions conditions)
conditions 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 conditions are joined by AND, AND NOT,
OR and OR NOT operators. These conditions is being a grouped condition,
and will be surrounded by parentheses.
See the second example.
// SELECT * FROM book WHERE year > 2010 OR NOT id BETWEEN 1 AND 10
select("*")
.from("book")
.where("year", ">", "2010")
.orNot(conditionBetween("id", "1", "10"))
.sql()
The second example:
// SELECT * FROM book WHERE year > 2010 OR NOT (id BETWEEN 1 AND 10 AND name = 'Advanced SQL')
select("*")
.from("book")
.where("year", ">", "2010")
.orNot(
conditionBetween("id", "1", "10")
..and(asName("name"), operator("="), asString("Advanced SQL"))
)
.sql()
conditions - conditionQueryman.condition(Object, Object, Object)Node getNode()