com.samskivert.jdbc.depot.clause
Class SelectClause<T extends PersistentRecord>

java.lang.Object
  extended by com.samskivert.jdbc.depot.clause.QueryClause
      extended by com.samskivert.jdbc.depot.clause.SelectClause<T>
All Implemented Interfaces:
SQLExpression

public class SelectClause<T extends PersistentRecord>
extends QueryClause

Builds actual SQL given a main persistent type and some QueryClause objects.


Field Summary
protected  Map<String,FieldDefinition> _disMap
          Persistent class fields mapped to field override clauses.
protected  String[] _fields
          The persistent fields to select.
protected  ForUpdate _forUpdate
          The For Update clause, if any.
protected  FromOverride _fromOverride
          The from override clause, if any.
protected  GroupBy _groupBy
          The group by clause, if any.
protected  List<Join> _joinClauses
          A list of join clauses, each potentially referencing a new class.
protected  Limit _limit
          The limit clause, if any.
protected  OrderBy _orderBy
          The order by clause, if any.
protected  Class<T> _pClass
          The persistent class this select defines.
protected  WhereClause _where
          The where clause.
 
Constructor Summary
SelectClause(Class<T> pClass, String[] fields, List<QueryClause> clauses)
          Creates a new Query object to generate one or more instances of the specified persistent class, as dictated by the key and query clauses.
SelectClause(Class<T> pClass, String[] fields, QueryClause... clauses)
          A varargs version of the constructor.
 
Method Summary
 void accept(ExpressionVisitor builder)
          Most uses of this class have been implemented with a visitor pattern.
 void addClasses(Collection<Class<? extends PersistentRecord>> classSet)
          Adds all persistent classes that are brought into the SQL context by this clause: FROM clauses, JOINs, UPDATEs, anything that could create a new table abbreviation.
 Collection<FieldDefinition> getFieldDefinitions()
           
 String[] getFields()
           
 ForUpdate getForUpdate()
           
 FromOverride getFromOverride()
           
 GroupBy getGroupBy()
           
 List<Join> getJoinClauses()
           
 Limit getLimit()
           
 OrderBy getOrderBy()
           
 Class<T> getPersistentClass()
           
 WhereClause getWhereClause()
           
 FieldDefinition lookupDefinition(String field)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_disMap

protected Map<String,FieldDefinition> _disMap
Persistent class fields mapped to field override clauses.


_pClass

protected Class<T extends PersistentRecord> _pClass
The persistent class this select defines.


_fields

protected String[] _fields
The persistent fields to select.


_fromOverride

protected FromOverride _fromOverride
The from override clause, if any.


_where

protected WhereClause _where
The where clause.


_joinClauses

protected List<Join> _joinClauses
A list of join clauses, each potentially referencing a new class.


_orderBy

protected OrderBy _orderBy
The order by clause, if any.


_groupBy

protected GroupBy _groupBy
The group by clause, if any.


_limit

protected Limit _limit
The limit clause, if any.


_forUpdate

protected ForUpdate _forUpdate
The For Update clause, if any.

Constructor Detail

SelectClause

public SelectClause(Class<T> pClass,
                    String[] fields,
                    List<QueryClause> clauses)
Creates a new Query object to generate one or more instances of the specified persistent class, as dictated by the key and query clauses. A persistence context is supplied for instantiation of marshallers, which may trigger table creations and schema migrations.


SelectClause

public SelectClause(Class<T> pClass,
                    String[] fields,
                    QueryClause... clauses)
A varargs version of the constructor.

Method Detail

lookupDefinition

public FieldDefinition lookupDefinition(String field)

getFieldDefinitions

public Collection<FieldDefinition> getFieldDefinitions()

getPersistentClass

public Class<T> getPersistentClass()

getFields

public String[] getFields()

getFromOverride

public FromOverride getFromOverride()

getWhereClause

public WhereClause getWhereClause()

getJoinClauses

public List<Join> getJoinClauses()

getOrderBy

public OrderBy getOrderBy()

getGroupBy

public GroupBy getGroupBy()

getLimit

public Limit getLimit()

getForUpdate

public ForUpdate getForUpdate()

addClasses

public void addClasses(Collection<Class<? extends PersistentRecord>> classSet)
Description copied from interface: SQLExpression
Adds all persistent classes that are brought into the SQL context by this clause: FROM clauses, JOINs, UPDATEs, anything that could create a new table abbreviation. This method should recurse into any subordinate state that may in turn bring in new classes so that sub-queries work correctly.


accept

public void accept(ExpressionVisitor builder)
            throws Exception
Description copied from interface: SQLExpression
Most uses of this class have been implemented with a visitor pattern. Create your own ExpressionVisitor and call this method with it.

Throws:
Exception
See Also:
SQLBuilder


Copyright © 2000-2008 Michael Bayne. All Rights Reserved.