org.sqlorm.querybuilder
Class SelectBuilder

java.lang.Object
  extended by org.sqlorm.querybuilder.SelectBuilder
All Implemented Interfaces:
ItfSelectBuilder

public class SelectBuilder
extends Object
implements ItfSelectBuilder

A class to easily create dynamic SELECT SQL

Author:
kasper graversen

Constructor Summary
SelectBuilder()
           
 
Method Summary
 MultiJoinOnExpr crossJoin(ITableName table)
           
 MultiJoinOnExpr crossJoin(ITableName table, String alias)
           
 MultiJoinOnExpr crossJoin(String table)
           
 MultiJoinOnExpr crossJoin(String table, String alias)
           
 ItfSelectBuilder distinct()
           
 ItfSelectBuilder from(ITableName from)
           
 ItfSelectBuilder from(ITableName from, String alias)
           
 ItfSelectBuilder from(ItfSelectBuilder subSelect, String alias)
           
 ItfSelectBuilder from(String from)
           
 ItfSelectBuilder from(String from, String alias)
           
 ItfSelectBuilder groupBy(ITableName table)
           
 ItfSelectBuilder groupBy(String... tableNames)
           
 SurogateAndOrListSelectBuilder having()
           
 MultiJoinOnExpr innerJoin(ITableName table)
           
 MultiJoinOnExpr innerJoin(ITableName table, String alias)
           
 MultiJoinOnExpr innerJoin(String table)
           
 MultiJoinOnExpr innerJoin(String table, String alias)
           
 ItfSelectBuilder internal_setAlias(String alias)
           
 ItfSelectBuilder internal_setIsNestedSelect()
           
 MultiJoinOnExpr leftJoin(ITableName table)
           
 MultiJoinOnExpr leftJoin(ITableName table, String alias)
           
 MultiJoinOnExpr leftJoin(String table)
           
 MultiJoinOnExpr leftJoin(String table, String alias)
           
 ItfSelectBuilder orderBy(ITableName table)
           
 ItfSelectBuilder orderBy(String tableName)
           
 ItfSelectBuilder orderByAsc(ITableName table)
           
 ItfSelectBuilder orderByAsc(String tableName)
           
 ItfSelectBuilder orderByDesc(ITableName table)
           
 ItfSelectBuilder orderByDesc(String tableName)
           
 MultiJoinOnExpr outerJoin(ITableName table)
           
 MultiJoinOnExpr outerJoin(ITableName table, String alias)
           
 MultiJoinOnExpr outerJoin(String table)
           
 MultiJoinOnExpr outerJoin(String table, String alias)
           
 MultiJoinOnExpr rightJoin(ITableName table)
           
 MultiJoinOnExpr rightJoin(ITableName table, String alias)
           
 MultiJoinOnExpr rightJoin(String table)
           
 MultiJoinOnExpr rightJoin(String table, String alias)
           
 ItfSelectBuilder select(IColumnName column)
           
 ItfSelectBuilder select(IColumnName column, String alias)
           
 ItfSelectBuilder select(String column)
          Select a column
 ItfSelectBuilder select(String column, String alias)
          Select a column
 String toSql()
          Call this method for generating an SQL expression from your object.
 void toSql(StringBuilder sb, String indent)
          Internal method for sql generation.
 SurogateAndOrListSelectBuilder where()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectBuilder

public SelectBuilder()
Method Detail

crossJoin

public MultiJoinOnExpr crossJoin(ITableName table)
Specified by:
crossJoin in interface ItfSelectBuilder

crossJoin

public MultiJoinOnExpr crossJoin(ITableName table,
                                 String alias)
Specified by:
crossJoin in interface ItfSelectBuilder

crossJoin

public MultiJoinOnExpr crossJoin(String table)
Specified by:
crossJoin in interface ItfSelectBuilder

crossJoin

public MultiJoinOnExpr crossJoin(String table,
                                 String alias)
Specified by:
crossJoin in interface ItfSelectBuilder

distinct

public ItfSelectBuilder distinct()
Specified by:
distinct in interface ItfSelectBuilder

from

public ItfSelectBuilder from(ITableName from)
Specified by:
from in interface ItfSelectBuilder

from

public ItfSelectBuilder from(ITableName from,
                             String alias)
Specified by:
from in interface ItfSelectBuilder

from

public ItfSelectBuilder from(ItfSelectBuilder subSelect,
                             String alias)
Specified by:
from in interface ItfSelectBuilder

from

public ItfSelectBuilder from(String from)
Specified by:
from in interface ItfSelectBuilder

from

public ItfSelectBuilder from(String from,
                             String alias)
Specified by:
from in interface ItfSelectBuilder

groupBy

public ItfSelectBuilder groupBy(ITableName table)
Specified by:
groupBy in interface ItfSelectBuilder

groupBy

public ItfSelectBuilder groupBy(String... tableNames)
Specified by:
groupBy in interface ItfSelectBuilder
Parameters:
string -
Returns:

having

public SurogateAndOrListSelectBuilder having()
Specified by:
having in interface ItfSelectBuilder

innerJoin

public MultiJoinOnExpr innerJoin(ITableName table)
Specified by:
innerJoin in interface ItfSelectBuilder

innerJoin

public MultiJoinOnExpr innerJoin(ITableName table,
                                 String alias)
Specified by:
innerJoin in interface ItfSelectBuilder

innerJoin

public MultiJoinOnExpr innerJoin(String table)
Specified by:
innerJoin in interface ItfSelectBuilder

innerJoin

public MultiJoinOnExpr innerJoin(String table,
                                 String alias)
Specified by:
innerJoin in interface ItfSelectBuilder

internal_setAlias

public ItfSelectBuilder internal_setAlias(String alias)
Specified by:
internal_setAlias in interface ItfSelectBuilder

internal_setIsNestedSelect

public ItfSelectBuilder internal_setIsNestedSelect()
Specified by:
internal_setIsNestedSelect in interface ItfSelectBuilder

leftJoin

public MultiJoinOnExpr leftJoin(ITableName table)
Specified by:
leftJoin in interface ItfSelectBuilder

leftJoin

public MultiJoinOnExpr leftJoin(ITableName table,
                                String alias)
Specified by:
leftJoin in interface ItfSelectBuilder

leftJoin

public MultiJoinOnExpr leftJoin(String table)
Specified by:
leftJoin in interface ItfSelectBuilder

leftJoin

public MultiJoinOnExpr leftJoin(String table,
                                String alias)
Specified by:
leftJoin in interface ItfSelectBuilder

orderBy

public ItfSelectBuilder orderBy(ITableName table)
Specified by:
orderBy in interface ItfSelectBuilder

orderBy

public ItfSelectBuilder orderBy(String tableName)
Specified by:
orderBy in interface ItfSelectBuilder

orderByAsc

public ItfSelectBuilder orderByAsc(ITableName table)
Specified by:
orderByAsc in interface ItfSelectBuilder

orderByAsc

public ItfSelectBuilder orderByAsc(String tableName)
Specified by:
orderByAsc in interface ItfSelectBuilder

orderByDesc

public ItfSelectBuilder orderByDesc(ITableName table)
Specified by:
orderByDesc in interface ItfSelectBuilder

orderByDesc

public ItfSelectBuilder orderByDesc(String tableName)
Specified by:
orderByDesc in interface ItfSelectBuilder

outerJoin

public MultiJoinOnExpr outerJoin(ITableName table)
Specified by:
outerJoin in interface ItfSelectBuilder

outerJoin

public MultiJoinOnExpr outerJoin(ITableName table,
                                 String alias)
Specified by:
outerJoin in interface ItfSelectBuilder

outerJoin

public MultiJoinOnExpr outerJoin(String table)
Specified by:
outerJoin in interface ItfSelectBuilder

outerJoin

public MultiJoinOnExpr outerJoin(String table,
                                 String alias)
Specified by:
outerJoin in interface ItfSelectBuilder

rightJoin

public MultiJoinOnExpr rightJoin(ITableName table)
Specified by:
rightJoin in interface ItfSelectBuilder

rightJoin

public MultiJoinOnExpr rightJoin(ITableName table,
                                 String alias)
Specified by:
rightJoin in interface ItfSelectBuilder

rightJoin

public MultiJoinOnExpr rightJoin(String table)
Specified by:
rightJoin in interface ItfSelectBuilder

rightJoin

public MultiJoinOnExpr rightJoin(String table,
                                 String alias)
Specified by:
rightJoin in interface ItfSelectBuilder

select

public ItfSelectBuilder select(String column)
Select a column

Specified by:
select in interface ItfSelectBuilder
Parameters:
column - the column to add to the SELECT part of an SQL expression
Returns:
this

select

public ItfSelectBuilder select(String column,
                               String alias)
Select a column

Specified by:
select in interface ItfSelectBuilder
Parameters:
column - The column to add to the SELECT part of an SQL expression
alias - the AS part when aliasing
Returns:
this

toSql

public String toSql()
Call this method for generating an SQL expression from your object.

Specified by:
toSql in interface ItfSelectBuilder
Returns:
An SQL expresion

toSql

public void toSql(StringBuilder sb,
                  String indent)
Internal method for sql generation. Use toSql(String) instead.

See Also:
toSql()

where

public SurogateAndOrListSelectBuilder where()
Specified by:
where in interface ItfSelectBuilder

select

public ItfSelectBuilder select(IColumnName column)
Specified by:
select in interface ItfSelectBuilder

select

public ItfSelectBuilder select(IColumnName column,
                               String alias)
Specified by:
select in interface ItfSelectBuilder