Class QueryCriteria
java.lang.Object
com.northconcepts.datapipeline.jdbc.sql.SqlPart
com.northconcepts.datapipeline.jdbc.sql.select.QueryPart
com.northconcepts.datapipeline.jdbc.sql.select.QueryCriteria
The WHERE or HAVING clause of a query, built from conditions combined with AND and OR; renders nothing when empty.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhether aQueryCriteriarenders as a WHERE or a HAVING clause. -
Constructor Summary
ConstructorsConstructorDescriptionQueryCriteria(String statement, Object... values) Creates WHERE criteria with one condition, such as"id = ?", and its parameter values. -
Method Summary
Modifier and TypeMethodDescriptionANDs (ifandConjunctionis true) or ORs a condition with its parameter values, first iffirstis true, and returns the root part.ANDs (ifandConjunctionis true) or ORs a condition with its parameter values and returns the root part.and(boolean first, QueryCriteriaPart part) ANDs the part with the existing conditions (first iffirstis true) and returns the rootAndPart.ANDs a condition with its parameter values (first iffirstis true) and returns the rootAndPart.and(QueryCriteriaPart part) ANDs the part after the existing conditions and returns the rootAndPart.ANDs a condition, such as"id = ?", with its parameter values and returns the rootAndPart.clear()voidcollectParameterValues(List<Object> values) Appends the values for this part's?parameters to the list in order; adds nothing by default.voidcollectSqlFragment(CodeWriter writer) Writes this part's SQL to the writer; used bySqlPart.getSqlFragment()and by enclosing parts.Returns the top-level part holding all conditions ornullif there are none.getType()Returns the clause this criteria renders as, WHERE (the default) or HAVING.booleanisEmpty()booleanor(boolean first, QueryCriteriaPart part) ORs the part with the existing conditions (first iffirstis true) and returns the rootOrPart.ORs a condition with its parameter values (first iffirstis true) and returns the rootOrPart.or(QueryCriteriaPart part) ORs the part after the existing conditions and returns the rootOrPart.ORs a condition, such as"id = ?", with its parameter values and returns the rootOrPart.setRootPart(QueryCriteriaPart rootPart) Replaces all conditions with the given part (nullremoves them).Sets the clause this criteria renders as, WHERE or HAVING;nullmeans WHERE.Methods inherited from class com.northconcepts.datapipeline.jdbc.sql.SqlPart
getParameterValues, getSqlFragment, isPretty, printSqlParts, setPretty, toString
-
Constructor Details
-
QueryCriteria
public QueryCriteria() -
QueryCriteria
-
QueryCriteria
Creates WHERE criteria with one condition, such as"id = ?", and its parameter values.
-
-
Method Details
-
isEmpty
public boolean isEmpty() -
isNotEmpty
public boolean isNotEmpty() -
clear
-
getType
Returns the clause this criteria renders as, WHERE (the default) or HAVING. -
setType
Sets the clause this criteria renders as, WHERE or HAVING;nullmeans WHERE. -
getRootPart
Returns the top-level part holding all conditions ornullif there are none. -
setRootPart
Replaces all conditions with the given part (nullremoves them). -
and
ANDs the part with the existing conditions (first iffirstis true) and returns the rootAndPart. -
and
ANDs the part after the existing conditions and returns the rootAndPart. -
and
ANDs a condition, such as"id = ?", with its parameter values and returns the rootAndPart. -
and
ANDs a condition with its parameter values (first iffirstis true) and returns the rootAndPart. -
or
ORs the part with the existing conditions (first iffirstis true) and returns the rootOrPart. -
or
ORs the part after the existing conditions and returns the rootOrPart. -
or
ORs a condition, such as"id = ?", with its parameter values and returns the rootOrPart. -
or
ORs a condition with its parameter values (first iffirstis true) and returns the rootOrPart. -
add
public ConjunctivePart add(boolean andConjunction, boolean first, String statement, Object... values) ANDs (ifandConjunctionis true) or ORs a condition with its parameter values, first iffirstis true, and returns the root part. -
add
ANDs (ifandConjunctionis true) or ORs a condition with its parameter values and returns the root part. -
collectSqlFragment
Description copied from class:SqlPartWrites this part's SQL to the writer; used bySqlPart.getSqlFragment()and by enclosing parts.- Specified by:
collectSqlFragmentin classSqlPart
-
collectParameterValues
Description copied from class:SqlPartAppends the values for this part's?parameters to the list in order; adds nothing by default.- Overrides:
collectParameterValuesin classSqlPart
-