Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.objectstyle.cayenne.access.trans
Class QueryAssembler  view QueryAssembler download QueryAssembler.java

java.lang.Object
  extended byorg.objectstyle.cayenne.access.QueryTranslator
      extended byorg.objectstyle.cayenne.access.trans.QueryAssembler
Direct Known Subclasses:
DeleteTranslator, InsertTranslator, SelectQueryAssembler, SelectTranslator, SqlModifyTranslator, SqlSelectTranslator, UpdateTranslator

public abstract class QueryAssembler
extends org.objectstyle.cayenne.access.QueryTranslator

Abstract superclass of Query translators.


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

Field Detail

logObj

private static org.apache.log4j.Logger logObj

values

protected java.util.List values
PreparedStatement values.


attributes

protected java.util.List attributes
PreparedStatement attributes matching entries in values list.

Constructor Detail

QueryAssembler

public QueryAssembler()
Method Detail

dbRelationshipAdded

public abstract void dbRelationshipAdded(org.objectstyle.cayenne.map.DbRelationship dbRel)
Processes a join being added.


createSqlString

public abstract java.lang.String createSqlString()
                                          throws java.lang.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.


aliasForTable

public java.lang.String aliasForTable(org.objectstyle.cayenne.map.DbEntity ent,
                                      org.objectstyle.cayenne.map.DbRelationship rel)

aliasForTable

public abstract java.lang.String aliasForTable(org.objectstyle.cayenne.map.DbEntity dbEnt)
Returns a name that can be used as column alias. This can be one of the following:
  • an alias for this table, if it uses aliases
  • a fully qualified table name, if not.
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(org.objectstyle.cayenne.map.DbAttribute dbAttr,
                           java.lang.Object anObject)
Registers anObject as a PreparedStatement paramter.


createStatement

public java.sql.PreparedStatement createStatement(org.apache.log4j.Level logLevel)
                                           throws java.lang.Exception
Translates internal query into PreparedStatement.


initStatement

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