net.amrhassan.sqlbuilder
Class SelectSqlStatement

java.lang.Object
  extended by net.amrhassan.sqlbuilder.SelectSqlStatement
All Implemented Interfaces:
SqlStatement

public final class SelectSqlStatement
extends Object
implements SqlStatement

A SELECT SQL statement


Nested Class Summary
static class SelectSqlStatement.Order
          The order specified in an ORDER BY clause
 
Constructor Summary
SelectSqlStatement()
           
 
Method Summary
 void addFieldAs(String name, String alias)
          Add a field to be selected.
 void addFields(String... names)
          Add a fields to be selected.
 void addGroupByFields(String... fields)
          Add a field to be used for the GROUP BY clause
 void addOrderBy(SelectSqlStatement.Order order, String... fields)
          Specify a field to be used for the ORDER BY clause
 void addOrderBy(String... fields)
          Specify fields to be used for the ORDER BY clause
 void addSource(SqlSource source)
          Add a source for the statement, which can be a simple table name or a complex JOIN clause (see SqlSources)
 void disableDistinct()
          Disable the DISTINCT clause
 void enableDistinct()
          Enable the DISTINCT clause
 void setRestriction(SqlRestriction restriction)
          The restrictions used in the WHERE clause
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectSqlStatement

public SelectSqlStatement()
Method Detail

enableDistinct

public void enableDistinct()
Enable the DISTINCT clause


disableDistinct

public void disableDistinct()
Disable the DISTINCT clause


addSource

public void addSource(SqlSource source)
Add a source for the statement, which can be a simple table name or a complex JOIN clause (see SqlSources)


addFieldAs

public void addFieldAs(String name,
                       String alias)
Add a field to be selected. Fields can be column names or aggregate function expressions.

Parameters:
name - Column name or aggregate function expression
alias - An alias for the specified field name

addFields

public void addFields(String... names)
Add a fields to be selected. Fields can be column names or aggregate function expressions.

Parameters:
names - Column names or aggregate function expression

addOrderBy

public void addOrderBy(String... fields)
Specify fields to be used for the ORDER BY clause

Parameters:
fields - The field names or their aliases if they were specified with aliases

addOrderBy

public void addOrderBy(SelectSqlStatement.Order order,
                       String... fields)
Specify a field to be used for the ORDER BY clause

Parameters:
fields - The field names or their aliases if they were specified with aliases
order - The order of the rows

addGroupByFields

public void addGroupByFields(String... fields)
Add a field to be used for the GROUP BY clause

Parameters:
field - The field name or its alias if it was specified with an alias

setRestriction

public void setRestriction(SqlRestriction restriction)
The restrictions used in the WHERE clause

Parameters:
restriction - (See SqlSources)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.