java.lang.Object
org.objectstyle.cayenne.access.trans.QueryAssemblerHelper
- Direct Known Subclasses:
- OrderingTranslator, QualifierTranslator
- public abstract class QueryAssemblerHelper
- extends java.lang.Object
Translates parts of the query to SQL.
Always works in the context of parent Translator.
|
Method Summary |
protected void |
appendDbPath(java.lang.StringBuffer buf,
org.objectstyle.cayenne.exp.Expression pathExp)
|
protected void |
appendLiteral(java.lang.StringBuffer buf,
java.lang.Object val,
org.objectstyle.cayenne.map.DbAttribute attr,
org.objectstyle.cayenne.exp.Expression parentExpression)
Appends SQL code to the query buffer to handle val as a
parameter to the PreparedStatement being built. |
protected void |
appendLiteralDirect(java.lang.StringBuffer buf,
java.lang.Object val,
org.objectstyle.cayenne.map.DbAttribute attr,
org.objectstyle.cayenne.exp.Expression parentExpression)
Appends SQL code to the query buffer to handle val as a
parameter to the PreparedStatement being built. |
protected void |
appendObjPath(java.lang.StringBuffer buf,
org.objectstyle.cayenne.exp.Expression pathExp)
Processes parts of the OBJ_PATH expression. |
abstract java.lang.String |
doTranslation()
Translates the part of parent translator's query that is supported
by this PartTranslator. |
org.objectstyle.cayenne.map.DbEntity |
getDbEntity()
|
org.objectstyle.cayenne.map.ObjEntity |
getObjEntity()
|
QueryAssembler |
getQueryAssembler()
Returns parent QueryAssembler that uses this helper. |
protected org.objectstyle.cayenne.map.DbAttribute |
paramsDbType(org.objectstyle.cayenne.exp.Expression e)
Returns database type of expression parameters or
null if it can not be determined. |
protected void |
processColumn(java.lang.StringBuffer buf,
org.objectstyle.cayenne.map.DbAttribute dbAttr)
|
protected void |
processColumn(java.lang.StringBuffer buf,
org.objectstyle.cayenne.map.DbAttribute dbAttr,
org.objectstyle.cayenne.map.DbRelationship rel)
|
protected void |
processColumn(java.lang.StringBuffer buf,
org.objectstyle.cayenne.exp.Expression nameExp)
Appends column name of a column in a root entity. |
protected void |
processRelTermination(java.lang.StringBuffer buf,
org.objectstyle.cayenne.map.DbRelationship rel)
Handles case when a DB_NAME expression ends with relationship. |
protected void |
processRelTermination(java.lang.StringBuffer buf,
org.objectstyle.cayenne.map.ObjRelationship rel)
Processes case when an OBJ_PATH expression ends with relationship. |
void |
setQueryAssembler(QueryAssembler queryAssembler)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logObj
private static org.apache.log4j.Logger logObj
queryAssembler
protected QueryAssembler queryAssembler
QueryAssemblerHelper
public QueryAssemblerHelper()
QueryAssemblerHelper
public QueryAssemblerHelper(QueryAssembler queryAssembler)
- Creates QueryAssemblerHelper. Sets queryAssembler property.
getQueryAssembler
public QueryAssembler getQueryAssembler()
- Returns parent QueryAssembler that uses this helper.
setQueryAssembler
public void setQueryAssembler(QueryAssembler queryAssembler)
doTranslation
public abstract java.lang.String doTranslation()
- Translates the part of parent translator's query that is supported
by this PartTranslator. For example, QualifierTranslator will process
qualifier expression, OrderingTranslator - ordering of the query.
In the process of translation parent translator is notified of any
join tables added (so that it can update its "FROM" clause).
Also parent translator is consulted about table aliases to use
when translating columns.
getObjEntity
public org.objectstyle.cayenne.map.ObjEntity getObjEntity()
getDbEntity
public org.objectstyle.cayenne.map.DbEntity getDbEntity()
appendObjPath
protected void appendObjPath(java.lang.StringBuffer buf,
org.objectstyle.cayenne.exp.Expression pathExp)
- Processes parts of the OBJ_PATH expression.
appendDbPath
protected void appendDbPath(java.lang.StringBuffer buf,
org.objectstyle.cayenne.exp.Expression pathExp)
processColumn
protected void processColumn(java.lang.StringBuffer buf,
org.objectstyle.cayenne.exp.Expression nameExp)
- Appends column name of a column in a root entity.
processColumn
protected void processColumn(java.lang.StringBuffer buf,
org.objectstyle.cayenne.map.DbAttribute dbAttr,
org.objectstyle.cayenne.map.DbRelationship rel)
processColumn
protected void processColumn(java.lang.StringBuffer buf,
org.objectstyle.cayenne.map.DbAttribute dbAttr)
appendLiteral
protected void appendLiteral(java.lang.StringBuffer buf,
java.lang.Object val,
org.objectstyle.cayenne.map.DbAttribute attr,
org.objectstyle.cayenne.exp.Expression parentExpression)
- Appends SQL code to the query buffer to handle
val as a
parameter to the PreparedStatement being built. Adds val
into QueryAssembler parameter list.
If val is null, "NULL" is appended to the query.
If val is a DataObject, its primary key value is
used as a parameter. Only objects with a single column primary key
can be used.
appendLiteralDirect
protected void appendLiteralDirect(java.lang.StringBuffer buf,
java.lang.Object val,
org.objectstyle.cayenne.map.DbAttribute attr,
org.objectstyle.cayenne.exp.Expression parentExpression)
- Appends SQL code to the query buffer to handle
val as a
parameter to the PreparedStatement being built. Adds val
into QueryAssembler parameter list.
paramsDbType
protected org.objectstyle.cayenne.map.DbAttribute paramsDbType(org.objectstyle.cayenne.exp.Expression e)
- Returns database type of expression parameters or
null if it can not be determined.
processRelTermination
protected void processRelTermination(java.lang.StringBuffer buf,
org.objectstyle.cayenne.map.ObjRelationship rel)
- Processes case when an OBJ_PATH expression ends with relationship.
If this is a "to many" relationship, a join is added and a column
expression for the target entity primary key. If this is a "to one"
relationship, column expresion for the source foreign key is added.
processRelTermination
protected void processRelTermination(java.lang.StringBuffer buf,
org.objectstyle.cayenne.map.DbRelationship rel)
- Handles case when a DB_NAME expression ends with relationship.
If this is a "to many" relationship, a join is added and a column
expression for the target entity primary key. If this is a "to one"
relationship, column expresion for the source foreign key is added.