Class QueryCriteria


public final class QueryCriteria extends QueryPart
The WHERE or HAVING clause of a query, built from conditions combined with AND and OR; renders nothing when empty.
  • Constructor Details

    • QueryCriteria

      public QueryCriteria()
    • QueryCriteria

      public QueryCriteria(QueryCriteria.CriteriaType type)
    • QueryCriteria

      public QueryCriteria(String statement, Object... values)
      Creates WHERE criteria with one condition, such as "id = ?", and its parameter values.
  • Method Details

    • isEmpty

      public boolean isEmpty()
    • isNotEmpty

      public boolean isNotEmpty()
    • clear

      public QueryCriteria clear()
    • getType

      public QueryCriteria.CriteriaType getType()
      Returns the clause this criteria renders as, WHERE (the default) or HAVING.
    • setType

      Sets the clause this criteria renders as, WHERE or HAVING; null means WHERE.
    • getRootPart

      public QueryCriteriaPart getRootPart()
      Returns the top-level part holding all conditions or null if there are none.
    • setRootPart

      public QueryCriteria setRootPart(QueryCriteriaPart rootPart)
      Replaces all conditions with the given part (null removes them).
    • and

      public AndPart and(boolean first, QueryCriteriaPart part)
      ANDs the part with the existing conditions (first if first is true) and returns the root AndPart.
    • and

      public AndPart and(QueryCriteriaPart part)
      ANDs the part after the existing conditions and returns the root AndPart.
    • and

      public AndPart and(String statement, Object... values)
      ANDs a condition, such as "id = ?", with its parameter values and returns the root AndPart.
    • and

      public AndPart and(boolean first, String statement, Object... values)
      ANDs a condition with its parameter values (first if first is true) and returns the root AndPart.
    • or

      public OrPart or(boolean first, QueryCriteriaPart part)
      ORs the part with the existing conditions (first if first is true) and returns the root OrPart.
    • or

      public OrPart or(QueryCriteriaPart part)
      ORs the part after the existing conditions and returns the root OrPart.
    • or

      public OrPart or(String statement, Object... values)
      ORs a condition, such as "id = ?", with its parameter values and returns the root OrPart.
    • or

      public OrPart or(boolean first, String statement, Object... values)
      ORs a condition with its parameter values (first if first is true) and returns the root OrPart.
    • add

      public ConjunctivePart add(boolean andConjunction, boolean first, String statement, Object... values)
      ANDs (if andConjunction is true) or ORs a condition with its parameter values, first if first is true, and returns the root part.
    • add

      public ConjunctivePart add(boolean andConjunction, String statement, Object... values)
      ANDs (if andConjunction is true) or ORs a condition with its parameter values and returns the root part.
    • collectSqlFragment

      public void collectSqlFragment(CodeWriter writer)
      Description copied from class: SqlPart
      Writes this part's SQL to the writer; used by SqlPart.getSqlFragment() and by enclosing parts.
      Specified by:
      collectSqlFragment in class SqlPart
    • collectParameterValues

      public void collectParameterValues(List<Object> values)
      Description copied from class: SqlPart
      Appends the values for this part's ? parameters to the list in order; adds nothing by default.
      Overrides:
      collectParameterValues in class SqlPart