All Implemented Interfaces:
ISqlBuilder, ISqlKeywords

public class SelectBuilder extends AbstractQuerySqlBuilder
The Select Builder.
  • Constructor Details

    • SelectBuilder

      public SelectBuilder(ISqlDialect dialect)
      Instantiates a new select builder.
      Parameters:
      dialect - the dialect
  • Method Details

    • distinct

      public SelectBuilder distinct()
      Distinct.
      Returns:
      the select builder
    • forUpdate

      public SelectBuilder forUpdate()
      For update.
      Returns:
      the select builder
    • column

      public SelectBuilder column(String column)
      Column.
      Parameters:
      column - the column
      Returns:
      the select builder
    • from

      public SelectBuilder from(String table)
      From.
      Parameters:
      table - the table
      Returns:
      the select builder
    • from

      public SelectBuilder from(String table, String alias)
      From.
      Parameters:
      table - the table
      alias - the alias
      Returns:
      the select builder
    • schema

      public SelectBuilder schema(String schema)
      From.
      Parameters:
      schema - the schema
      Returns:
      the select builder
    • join

      public SelectBuilder join(String table, String on)
      Join.
      Parameters:
      table - the table
      on - the on
      Returns:
      the select builder
    • join

      public SelectBuilder join(String table, String on, String alias)
      Join.
      Parameters:
      table - the table
      on - the on
      alias - the alias
      Returns:
      the select builder
    • innerJoin

      public SelectBuilder innerJoin(String table, String on)
      Inner join.
      Parameters:
      table - the table
      on - the on
      Returns:
      the select builder
    • innerJoin

      public SelectBuilder innerJoin(String table, String on, String alias)
      Inner join.
      Parameters:
      table - the table
      on - the on
      alias - the alias
      Returns:
      the select builder
    • outerJoin

      public SelectBuilder outerJoin(String table, String on)
      Outer join.
      Parameters:
      table - the table
      on - the on
      Returns:
      the select builder
    • outerJoin

      public SelectBuilder outerJoin(String table, String on, String alias)
      Outer join.
      Parameters:
      table - the table
      on - the on
      alias - the alias
      Returns:
      the select builder
    • leftJoin

      public SelectBuilder leftJoin(String table, String on)
      Left join.
      Parameters:
      table - the table
      on - the on
      Returns:
      the select builder
    • leftJoin

      public SelectBuilder leftJoin(String table, String on, String alias)
      Left join.
      Parameters:
      table - the table
      on - the on
      alias - the alias
      Returns:
      the select builder
    • rightJoin

      public SelectBuilder rightJoin(String table, String on)
      Right join.
      Parameters:
      table - the table
      on - the on
      Returns:
      the select builder
    • rightJoin

      public SelectBuilder rightJoin(String table, String on, String alias)
      Right join.
      Parameters:
      table - the table
      on - the on
      alias - the alias
      Returns:
      the select builder
    • fullJoin

      public SelectBuilder fullJoin(String table, String on)
      Full join.
      Parameters:
      table - the table
      on - the on
      Returns:
      the select builder
    • fullJoin

      public SelectBuilder fullJoin(String table, String on, String alias)
      Full join.
      Parameters:
      table - the table
      on - the on
      alias - the alias
      Returns:
      the select builder
    • genericJoin

      public SelectBuilder genericJoin(String type, String table, String on, String alias)
      Generic join.
      Parameters:
      type - the type
      table - the table
      on - the on
      alias - the alias
      Returns:
      the select builder
    • where

      public SelectBuilder where(String condition)
      Where.
      Parameters:
      condition - the condition
      Returns:
      the select builder
    • order

      public SelectBuilder order(String column)
      Order.
      Parameters:
      column - the column
      Returns:
      the select builder
    • order

      public SelectBuilder order(String column, boolean asc)
      Order.
      Parameters:
      column - the column
      asc - the asc
      Returns:
      the select builder
    • group

      public SelectBuilder group(String column)
      Group.
      Parameters:
      column - the column
      Returns:
      the select builder
    • limit

      public SelectBuilder limit(int limit)
      Limit.
      Parameters:
      limit - the limit
      Returns:
      the select builder
    • limit

      public SelectBuilder limit(Double limit)
      Limit.
      Parameters:
      limit - the limit
      Returns:
      the select builder
    • offset

      public SelectBuilder offset(int offset)
      Offset.
      Parameters:
      offset - the offset
      Returns:
      the select builder
    • offset

      public SelectBuilder offset(Double offset)
      Offset.
      Parameters:
      offset - the offset
      Returns:
      the select builder
    • having

      public SelectBuilder having(String having)
      Having.
      Parameters:
      having - the having
      Returns:
      the select builder
    • union

      public SelectBuilder union(String select)
      Union.
      Parameters:
      select - the select
      Returns:
      the select builder
    • generate

      public String generate()
      Generate.
      Returns:
      the string
    • generateUnion

      protected void generateUnion(StringBuilder sql)
      Generate union.
      Parameters:
      sql - the sql
    • generateHaving

      protected void generateHaving(StringBuilder sql)
      Generate having.
      Parameters:
      sql - the sql
    • generateGroupBy

      protected void generateGroupBy(StringBuilder sql)
      Generate group by.
      Parameters:
      sql - the sql
    • generateJoins

      protected void generateJoins(StringBuilder sql)
      Generate joins.
      Parameters:
      sql - the sql
    • generateTables

      protected void generateTables(StringBuilder sql)
      Generate tables.
      Parameters:
      sql - the sql
    • generateColumns

      protected void generateColumns(StringBuilder sql)
      Generate columns.
      Parameters:
      sql - the sql
    • generateDistinct

      protected void generateDistinct(StringBuilder sql)
      Generate distinct.
      Parameters:
      sql - the sql
    • generateForUpdate

      protected void generateForUpdate(StringBuilder sql)
      Generate for update.
      Parameters:
      sql - the sql
    • traverseColumns

      protected String traverseColumns()
      Traverse columns.
      Returns:
      the string
    • traverseTables

      protected String traverseTables()
      Traverse tables.
      Returns:
      the string
    • traverseJoins

      protected String traverseJoins()
      Traverse joins.
      Returns:
      the string
    • traverseGroups

      protected String traverseGroups()
      Traverse groups.
      Returns:
      the string
    • traverseUnions

      protected String traverseUnions()
      Traverse unions.
      Returns:
      the string
    • generateSelect

      protected void generateSelect(StringBuilder sql)
      Generate select.
      Parameters:
      sql - the sql
    • getColumns

      public List<String> getColumns()
      Gets the columns.
      Returns:
      the columns
    • getTables

      public List<String> getTables()
      Gets the tables.
      Returns:
      the tables
    • getJoins

      public List<String> getJoins()
      Gets the joins.
      Returns:
      the joins
    • getWheres

      public List<String> getWheres()
      Gets the wheres.
      Returns:
      the wheres
    • getOrders

      public List<String> getOrders()
      Gets the orders.
      Returns:
      the orders
    • getGroups

      public List<String> getGroups()
      Gets the groups.
      Returns:
      the groups
    • getUnions

      public List<String> getUnions()
      Gets the unions.
      Returns:
      the unions
    • isDistinct

      public boolean isDistinct()
      Checks if is distinct.
      Returns:
      true, if is distinct
    • getHaving

      public String getHaving()
      Gets the having.
      Returns:
      the having
    • getLimit

      public int getLimit()
      Gets the limit.
      Returns:
      the limit
    • getOffset

      public int getOffset()
      Gets the offset.
      Returns:
      the offset
    • isForUpdate

      public boolean isForUpdate()
      Checks if is for update.
      Returns:
      true, if is for update