com.uwyn.rife.database.queries
Class Select

java.lang.Object
  extended by com.uwyn.rife.database.queries.AbstractWhereQuery<Select>
      extended by com.uwyn.rife.database.queries.Select
All Implemented Interfaces:
Query, ReadQuery, Cloneable

public class Select
extends AbstractWhereQuery<Select>
implements Cloneable, ReadQuery

Object representation of a SQL "SELECT" query.

This object may be used to dynamically construct a SQL statement in a database-independent fashion. After it is finished, it may be executed using one of the query methods on DbQueryManager.

Since:
1.0
Version:
$Revision: 3648 $
Author:
Geert Bevin (gbevin[remove] at uwyn dot com), Steven Grimm (koreth[remove] at midwinter dot com)

Nested Class Summary
 class Select.Join
           
static class Select.JoinCondition
           
 class Select.JoinCross
           
 class Select.JoinCustom
           
 class Select.JoinDefault
           
 class Select.JoinInner
           
 class Select.JoinOuter
           
static class Select.JoinType
           
 class Select.OrderBy
           
static class Select.OrderByDirection
           
 class Select.Union
           
 
Field Summary
static Select.OrderByDirection ASC
           
static Select.OrderByDirection DESC
           
static Select.JoinType FULL
           
static Select.JoinType LEFT
           
protected  Datasource mDatasource
           
protected  boolean mExcludeUnsupportedCapabilities
           
protected  String mSql
           
static Select.JoinCondition NATURAL
           
static Select.JoinCondition ON
           
static Select.JoinType RIGHT
           
static Select.JoinCondition USING
           
 
Fields inherited from class com.uwyn.rife.database.queries.AbstractWhereQuery
mWhere
 
Constructor Summary
Select(Datasource datasource)
           
Select(Datasource datasource, Class constrainedClass)
           
 
Method Summary
protected  void _fieldSubselect(Select query)
           
protected  void _tableSubselect(Select query)
           
protected  void _unionSubselect(Select query)
           
protected  void _whereSubselect(Select query)
           
protected  void addFieldParameter(String field)
           
protected  void addWhereParameter(String field)
           
 void addWhereParameters(List<String> parameters)
           
 void addWhereParameters(List<String> parameters)
           
 void clear()
           
 void clearGenerated()
           
protected  void clearWhereParameters()
           
 Select clone()
           
 Select distinct()
           
 Select distinctOn(String... columns)
           
 Select distinctOn(String column)
           
 Select field(String field)
           
 Select field(String alias, Select query)
           
 Select fields(Class beanClass)
           
 Select fields(String... fields)
           
 Select fields(String table, Class beanClass)
           
 Select fieldsExcluded(Class beanClass, String... excludedFields)
           
 Select fieldsExcluded(String table, Class beanClass, String... excludedFields)
           
 Select fieldSubselect(Select query)
           
 Select from(Select query)
           
 Select from(String from)
           
 Select from(String alias, Select query)
           
 com.uwyn.rife.database.capabilities.Capabilities getCapabilities()
           
 Datasource getDatasource()
           
 Collection<String> getDistinctOn()
           
 Collection<String> getFields()
           
 String getFrom()
           
 Collection<String> getGroupBy()
           
 Collection<String> getHaving()
           
 String getHint()
           
 Collection<Select.Join> getJoins()
           
 int getLimit()
           
 String getLimitParameter()
           
 int getOffset()
           
 String getOffsetParameter()
           
 Collection<Select.OrderBy> getOrderBy()
           
 QueryParameters getParameters()
           
 String getSql()
           
protected  Template getTemplate()
           
 Collection<Select.Union> getUnions()
           
protected  List<String> getWhereParameters()
           
 Select groupBy(Class beanClass)
           
 Select groupBy(String groupBy)
           
 Select groupByExcluded(Class beanClass, String... excludedFields)
           
 Select having(String having)
           
 Select hint(String hint)
           
 boolean isDistinct()
           
protected  boolean isLimitBeforeOffset()
           
 Select join(String table)
           
 Select join(String alias, Select query)
           
 Select joinCross(String table)
           
 Select joinCustom(String customJoin)
           
 Select joinInner(String table, Select.JoinCondition condition, String conditionExpression)
           
 Select joinOuter(String table, Select.JoinType type, Select.JoinCondition condition, String conditionExpression)
           
 Select limit(int limit)
           
 Select limitParameter(String name)
           
 Select offset(int offset)
           
 Select offsetParameter(String name)
           
 Select orderBy(String column)
           
 Select orderBy(String column, Select.OrderByDirection direction)
           
 void setExcludeUnsupportedCapabilities(boolean flag)
           
protected  void setLimitParameter(String limitParameter)
           
protected  void setOffsetParameter(String offsetParameter)
           
 Select tableSubselect(Select query)
           
 String toString()
           
 Select union(Select union)
           
 Select union(String union)
           
 Select unionAll(Select union)
           
 Select unionAll(String union)
           
 
Methods inherited from class com.uwyn.rife.database.queries.AbstractWhereQuery
getWhere, startWhere, startWhereAnd, startWhereOr, where, where, where, where, where, where, where, where, where, where, where, where, whereAnd, whereAnd, whereAnd, whereAnd, whereAnd, whereAnd, whereAnd, whereAnd, whereAnd, whereAnd, whereAnd, whereExcluded, whereFiltered, whereIncluded, whereOr, whereOr, whereOr, whereOr, whereOr, whereOr, whereOr, whereOr, whereOr, whereOr, whereOr, whereParameter, whereParameter, whereParameterAnd, whereParameterAnd, whereParameterOr, whereParameterOr, whereParameters, whereParametersExcluded, whereSubselect
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.uwyn.rife.database.queries.Query
getParameters, setExcludeUnsupportedCapabilities
 

Field Detail

NATURAL

public static final Select.JoinCondition NATURAL

ON

public static final Select.JoinCondition ON

USING

public static final Select.JoinCondition USING

LEFT

public static final Select.JoinType LEFT

RIGHT

public static final Select.JoinType RIGHT

FULL

public static final Select.JoinType FULL

ASC

public static final Select.OrderByDirection ASC

DESC

public static final Select.OrderByDirection DESC

mDatasource

protected Datasource mDatasource

mSql

protected String mSql

mExcludeUnsupportedCapabilities

protected boolean mExcludeUnsupportedCapabilities
Constructor Detail

Select

public Select(Datasource datasource)

Select

public Select(Datasource datasource,
              Class constrainedClass)
Method Detail

clear

public void clear()
Specified by:
clear in interface Query
Overrides:
clear in class AbstractWhereQuery<Select>

clearGenerated

public void clearGenerated()

getHint

public String getHint()

getFields

public Collection<String> getFields()

isDistinct

public boolean isDistinct()

getDistinctOn

public Collection<String> getDistinctOn()

getFrom

public String getFrom()

getJoins

public Collection<Select.Join> getJoins()

getGroupBy

public Collection<String> getGroupBy()

getHaving

public Collection<String> getHaving()

getUnions

public Collection<Select.Union> getUnions()

getOrderBy

public Collection<Select.OrderBy> getOrderBy()

getLimit

public int getLimit()

getOffset

public int getOffset()

getTemplate

protected Template getTemplate()

getCapabilities

public com.uwyn.rife.database.capabilities.Capabilities getCapabilities()
Specified by:
getCapabilities in interface Query

getSql

public String getSql()
              throws DbQueryException
Specified by:
getSql in interface Query
Throws:
DbQueryException

hint

public Select hint(String hint)

field

public Select field(String field)

field

public Select field(String alias,
                    Select query)

fields

public Select fields(Class beanClass)
              throws DbQueryException
Throws:
DbQueryException

fieldsExcluded

public Select fieldsExcluded(Class beanClass,
                             String... excludedFields)
                      throws DbQueryException
Throws:
DbQueryException

fields

public Select fields(String table,
                     Class beanClass)
              throws DbQueryException
Throws:
DbQueryException

fieldsExcluded

public Select fieldsExcluded(String table,
                             Class beanClass,
                             String... excludedFields)
                      throws DbQueryException
Throws:
DbQueryException

fields

public Select fields(String... fields)

distinct

public Select distinct()

distinctOn

public Select distinctOn(String column)

distinctOn

public Select distinctOn(String... columns)

from

public Select from(String from)

from

public Select from(Select query)

from

public Select from(String alias,
                   Select query)

join

public Select join(String table)

join

public Select join(String alias,
                   Select query)

joinCustom

public Select joinCustom(String customJoin)

joinCross

public Select joinCross(String table)

joinInner

public Select joinInner(String table,
                        Select.JoinCondition condition,
                        String conditionExpression)

joinOuter

public Select joinOuter(String table,
                        Select.JoinType type,
                        Select.JoinCondition condition,
                        String conditionExpression)

fieldSubselect

public Select fieldSubselect(Select query)

tableSubselect

public Select tableSubselect(Select query)

groupBy

public Select groupBy(String groupBy)

groupBy

public Select groupBy(Class beanClass)
               throws DbQueryException
Throws:
DbQueryException

groupByExcluded

public Select groupByExcluded(Class beanClass,
                              String... excludedFields)
                       throws DbQueryException
Throws:
DbQueryException

having

public Select having(String having)

union

public Select union(String union)

union

public Select union(Select union)
             throws DbQueryException
Throws:
DbQueryException

unionAll

public Select unionAll(String union)

unionAll

public Select unionAll(Select union)
                throws DbQueryException
Throws:
DbQueryException

orderBy

public Select orderBy(String column)

orderBy

public Select orderBy(String column,
                      Select.OrderByDirection direction)

limit

public Select limit(int limit)

limitParameter

public Select limitParameter(String name)

offset

public Select offset(int offset)

isLimitBeforeOffset

protected boolean isLimitBeforeOffset()

offsetParameter

public Select offsetParameter(String name)

clone

public Select clone()
Overrides:
clone in class AbstractWhereQuery<Select>

addWhereParameters

public void addWhereParameters(List<String> parameters)

_fieldSubselect

protected void _fieldSubselect(Select query)

_tableSubselect

protected void _tableSubselect(Select query)

_whereSubselect

protected void _whereSubselect(Select query)

_unionSubselect

protected void _unionSubselect(Select query)

getParameters

public QueryParameters getParameters()
Specified by:
getParameters in interface Query

addFieldParameter

protected void addFieldParameter(String field)

clearWhereParameters

protected void clearWhereParameters()

addWhereParameter

protected void addWhereParameter(String field)

getWhereParameters

protected List<String> getWhereParameters()

addWhereParameters

public void addWhereParameters(List<String> parameters)

setLimitParameter

protected void setLimitParameter(String limitParameter)

getLimitParameter

public String getLimitParameter()

setOffsetParameter

protected void setOffsetParameter(String offsetParameter)

getOffsetParameter

public String getOffsetParameter()

getDatasource

public Datasource getDatasource()

setExcludeUnsupportedCapabilities

public void setExcludeUnsupportedCapabilities(boolean flag)
Specified by:
setExcludeUnsupportedCapabilities in interface Query

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.