public class Union extends QuerySource
Combines several Select queries with UNION or UNION ALL; can be nested in another query as a source.
  • Constructor Details

    • Union

      public Union(Select... selects)
      Creates a union of the given queries; at least one is required.
  • Method Details

    • add

      public Union add(Select... selects)
      Appends queries to the union; at least one must be given.
    • clear

      public Union clear()
    • getSelects

      public List<Select> getSelects()
    • isAll

      public boolean isAll()
      Indicates if the queries are combined with UNION ALL instead of UNION (default is false).
    • setAll

      public Union setAll(boolean all)
      Indicates if the queries are combined with UNION ALL instead of UNION (default is false).
    • setPretty

      public Union setPretty(boolean pretty)
      Description copied from class: SqlPart
      Indicates if SqlPart.getSqlFragment() adds line breaks and indentation instead of using one line (default is false).
      Overrides:
      setPretty in class QuerySource
    • setNestedAlias

      public Union setNestedAlias(String nestedAlias)
      Description copied from class: QuerySource
      Sets the alias written after this source in a FROM clause (null for none).
      Overrides:
      setNestedAlias in class QuerySource
    • getTables

      public List<String> getTables()
      Description copied from class: QuerySource
      Returns the tables this source reads from, including those of nested sources but not joined tables.
      Specified by:
      getTables in class QuerySource
    • getTable

      public String getTable()
      Description copied from class: QuerySource

      Returns the first table in the list of tables.


      If this query source involves more than one table, use QuerySource.getTables() instead of this method.
      Specified by:
      getTable in class QuerySource
    • containsTable

      public boolean containsTable(String table)
      Description copied from class: QuerySource
      Returns true if this source, a nested source or a join refers to the table (ignoring case).
      Specified by:
      containsTable in class QuerySource
    • 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