org.opencms.db
Class CmsSelectQuery

java.lang.Object
  extended by org.opencms.db.CmsSelectQuery
All Implemented Interfaces:
I_CmsQueryFragment

public class CmsSelectQuery
extends Object
implements I_CmsQueryFragment

A class for generating SQL SELECT statements.

Since:
8.0.0

Nested Class Summary
 class CmsSelectQuery.TableAlias
          Helper class which wraps a table alias.
 
Constructor Summary
CmsSelectQuery()
          Creates a new instance.
 
Method Summary
 void addClause(I_CmsQueryFragment clause)
          Adds another clause to the query.
 void addColumn(I_CmsQueryFragment node)
          Adds an expression which should be added as a column in the result set.
 void addColumn(String column)
          Adds an expression which should be added as a column in the result set.
 void addCondition(I_CmsQueryFragment node)
          Adds a new condition to the query.
 void addCondition(String fragment, Object... params)
          Adds a new condition to the query.
 void addTable(String table)
          Adds a table to the query's FROM clause.
 CmsSelectQuery.TableAlias addTable(String table, String aliasPrefix)
          Adds a table the query's FROM clause.
 I_CmsQueryFragment getOrdering()
          Returns the fragment for the ORDER BY clause.
 void setOrdering(String ordering)
          Sets the SQL used for the ORDER BY clause.
 void visit(CmsStatementBuilder builder)
          Generates the SQL and parameters and sends them to the statement builder .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsSelectQuery

public CmsSelectQuery()
Creates a new instance.

Method Detail

addClause

public void addClause(I_CmsQueryFragment clause)
Adds another clause to the query.

Parameters:
clause - the clause to add

addColumn

public void addColumn(I_CmsQueryFragment node)
Adds an expression which should be added as a column in the result set.

Parameters:
node - the expression which should be added as a column

addColumn

public void addColumn(String column)
Adds an expression which should be added as a column in the result set.

Parameters:
column - the expression which should be added as a column

addCondition

public void addCondition(I_CmsQueryFragment node)
Adds a new condition to the query.

Parameters:
node - the condition to add to the query

addCondition

public void addCondition(String fragment,
                         Object... params)
Adds a new condition to the query.

Parameters:
fragment - the condition SQL
params - the condition parameters

addTable

public void addTable(String table)
Adds a table to the query's FROM clause.

Parameters:
table - the table to add

addTable

public CmsSelectQuery.TableAlias addTable(String table,
                                          String aliasPrefix)
Adds a table the query's FROM clause.

Parameters:
table - the table to add
aliasPrefix - the prefix used to generate the alias
Returns:
an alias for the table

getOrdering

public I_CmsQueryFragment getOrdering()
Returns the fragment for the ORDER BY clause.

Returns:
the fragment for the ORDER BY clause

setOrdering

public void setOrdering(String ordering)
Sets the SQL used for the ORDER BY clause.

Parameters:
ordering - the SQL used for the ORDER BY clause

visit

public void visit(CmsStatementBuilder builder)
Description copied from interface: I_CmsQueryFragment
Generates the SQL and parameters and sends them to the statement builder .

Specified by:
visit in interface I_CmsQueryFragment
Parameters:
builder - the statement builder
See Also:
I_CmsQueryFragment.visit(org.opencms.db.CmsStatementBuilder)