org.apache.cayenne.access.trans
Class QueryAssembler

java.lang.Object
  extended by org.apache.cayenne.access.QueryTranslator
      extended by org.apache.cayenne.access.trans.QueryAssembler
Direct Known Subclasses:
DeleteTranslator, SelectTranslator, UpdateTranslator

public abstract class QueryAssembler
extends QueryTranslator

Abstract superclass of Query translators.

Author:
Andrus Adamchik

Field Summary
protected  List attributes
          PreparedStatement attributes matching entries in values list.
protected  List values
          PreparedStatement values.
 
Fields inherited from class org.apache.cayenne.access.QueryTranslator
adapter, connection, entityResolver, query
 
Constructor Summary
QueryAssembler()
           
 
Method Summary
 void addToParamList(DbAttribute dbAttr, Object anObject)
          Registers anObject as a PreparedStatement paramter.
abstract  String aliasForTable(DbEntity dbEnt)
          Returns a name that can be used as column alias.
 String aliasForTable(DbEntity ent, DbRelationship rel)
           
abstract  String createSqlString()
          Translates query into sql string.
 PreparedStatement createStatement()
          Translates internal query into PreparedStatement.
abstract  void dbRelationshipAdded(DbRelationship dbRel)
          Processes a join being added.
protected  void initStatement(PreparedStatement stmt)
          Initializes prepared statements with collected parameters.
 boolean supportsTableAliases()
          Returns true if table aliases are supported.
 
Methods inherited from class org.apache.cayenne.access.QueryTranslator
getAdapter, getConnection, getEntityResolver, getQuery, getRootDbEntity, getRootEntity, getRootInheritanceTree, setAdapter, setConnection, setEntityResolver, setQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

values

protected List values
PreparedStatement values.


attributes

protected List attributes
PreparedStatement attributes matching entries in values list.

Constructor Detail

QueryAssembler

public QueryAssembler()
Method Detail

dbRelationshipAdded

public abstract void dbRelationshipAdded(DbRelationship dbRel)
Processes a join being added.


createSqlString

public abstract String createSqlString()
                                throws Exception
Translates query into sql string. This is a workhorse method of QueryAssembler. It is called internally from createStatement. Usually there is no need to invoke it explicitly.

Throws:
Exception

aliasForTable

public String aliasForTable(DbEntity ent,
                            DbRelationship rel)

aliasForTable

public abstract String aliasForTable(DbEntity dbEnt)
Returns a name that can be used as column alias. This can be one of the following: CayenneRuntimeException is thrown if a table alias can not be created.


supportsTableAliases

public boolean supportsTableAliases()
Returns true if table aliases are supported. Default implementation returns false.


addToParamList

public void addToParamList(DbAttribute dbAttr,
                           Object anObject)
Registers anObject as a PreparedStatement paramter.

Parameters:
anObject - object that represents a value of DbAttribute
dbAttr - DbAttribute being processed.

createStatement

public PreparedStatement createStatement()
                                  throws Exception
Translates internal query into PreparedStatement.

Specified by:
createStatement in class QueryTranslator
Throws:
Exception

initStatement

protected void initStatement(PreparedStatement stmt)
                      throws Exception
Initializes prepared statements with collected parameters. Called internally from "createStatement". Cayenne users shouldn't normally call it directly.

Throws:
Exception


Copyright © 2001-2007 Apache Cayenne. All Rights Reserved.