Class QualifierTranslator
java.lang.Object
org.apache.cayenne.access.translator.select.QueryAssemblerHelper
org.apache.cayenne.access.translator.select.QualifierTranslator
- All Implemented Interfaces:
TraversalHandler
- Direct Known Subclasses:
FirebirdQualifierTranslator,FrontBaseQualifierTranslator,OpenBaseQualifierTranslator,SQLiteQualifierTranslator,SybaseQualifierTranslator,TrimmingQualifierTranslator
public class QualifierTranslator extends QueryAssemblerHelper implements TraversalHandler
Translates query qualifier to SQL. Used as a helper class by query
translators.
-
Field Summary
Fields Modifier and Type Field Description protected booleancaseInsensitiveprotected booleanmatchingObjectprotected DataObjectMatchTranslatorobjectMatchTranslatorprotected Expressionqualifierprotected booleanuseAliasForExpressionsprotected ExpressionwaitingForEndNodeFields inherited from class org.apache.cayenne.access.translator.select.QueryAssemblerHelper
out, queryAssembler, strategy -
Constructor Summary
Constructors Constructor Description QualifierTranslator(QueryAssembler queryAssembler) -
Method Summary
Modifier and Type Method Description protected voidappendExtractFunction(ASTExtract functionExpression)Special case for extract date/time parts functions as they have many variantsprotected voidappendFunction(ASTFunctionCall functionExpression)Append function name to result SQL Override this method to rename or skip function if generic name isn't supported on target DB.protected voidappendFunctionArg(Object value, ASTFunctionCall functionExpression)Append scalar argument of a function call Used only for values stored in ASTScalar other expressions appended in objectNode() methodprotected voidappendFunctionArgDivider(ASTFunctionCall functionExpression)Append divider between function arguments.protected voidappendLiteral(Object val, DbAttribute attr, Expression parentExpression)Appends SQL code to the query buffer to handlevalas a parameter to the PreparedStatement being built.protected voidappendObjectMatch()protected voidclearLastFunctionArgDivider(ASTFunctionCall functionExpression)Clear last divider as we currently don't now position of argument until parent element is ended.protected voiddetectObjectMatch(Expression exp)Called before processing an expression to initialize objectMatchTranslator if needed.protected voiddoAppendPart()Translates query qualifier to SQL WHERE clause.protected voiddoAppendPart(Expression rootNode)Translates query qualifier to SQL WHERE clause.voidendNode(Expression node, Expression parentNode)Called during the traversal after an expression node children processing is finished.protected ExpressionextractQualifier()voidfinishedChild(Expression node, int childIndex, boolean hasMoreChildren)Called during traversal after a child of expression has been visited.voidobjectNode(Object leaf, Expression parentNode)Called during the traversal when a leaf non-expression node is encountered.protected StringoperandForBitwiseAnd()protected StringoperandForBitwiseLeftShift()protected StringoperandForBitwiseNot()protected StringoperandForBitwiseOr()protected StringoperandForBitwiseRightShift()protected StringoperandForBitwiseXor()protected booleanparenthesisNeeded(Expression node, Expression parentNode)protected voidprocessRelTermination(DbRelationship rel, JoinType joinType, String joinSplitAlias)Handles case when a DB_NAME expression ends with relationship.voidsetCaseInsensitive(boolean caseInsensitive)voidsetQualifier(Expression qualifier)Explicitly set qualifier.voidsetUseAliasForExpressions(boolean useAliasForExpressions)voidstartNode(Expression node, Expression parentNode)Called during the traversal before an expression node children processing is started.Methods inherited from class org.apache.cayenne.access.translator.select.QueryAssemblerHelper
appendDbPath, appendLikeEscapeCharacter, appendLiteralDirect, appendObjPath, appendPart, getDbEntity, getObjEntity, paramsDbType, processColumn, processColumnWithQuoteSqlIdentifiers, processRelTermination, setForceJoinForRelations
-
Field Details
-
objectMatchTranslator
-
matchingObject
protected boolean matchingObject -
caseInsensitive
protected boolean caseInsensitive -
useAliasForExpressions
protected boolean useAliasForExpressions- Since:
- 4.0
-
waitingForEndNode
- Since:
- 4.0
-
qualifier
- Since:
- 4.0
-
-
Constructor Details
-
QualifierTranslator
-
-
Method Details
-
doAppendPart
protected void doAppendPart()Translates query qualifier to SQL WHERE clause. Qualifier is obtained from the parent queryAssembler.- Specified by:
doAppendPartin classQueryAssemblerHelper- Since:
- 3.0
-
setCaseInsensitive
public void setCaseInsensitive(boolean caseInsensitive) -
setQualifier
Explicitly set qualifier. It will be used instead of extracting qualifier from the query itself.- Since:
- 4.0
-
setUseAliasForExpressions
public void setUseAliasForExpressions(boolean useAliasForExpressions)- Since:
- 4.0
-
doAppendPart
Translates query qualifier to SQL WHERE clause. Qualifier is a method parameter.- Since:
- 3.0
-
extractQualifier
-
detectObjectMatch
Called before processing an expression to initialize objectMatchTranslator if needed. -
appendObjectMatch
- Throws:
IOException
-
finishedChild
Description copied from interface:TraversalHandlerCalled during traversal after a child of expression has been visited.- Specified by:
finishedChildin interfaceTraversalHandler
-
operandForBitwiseNot
- Since:
- 3.1
-
operandForBitwiseOr
- Since:
- 3.1
-
operandForBitwiseAnd
- Since:
- 3.1
-
operandForBitwiseXor
- Since:
- 3.1
-
operandForBitwiseLeftShift
- Since:
- 4.0
-
operandForBitwiseRightShift
- Since:
- 4.0
-
startNode
Description copied from interface:TraversalHandlerCalled during the traversal before an expression node children processing is started.- Specified by:
startNodein interfaceTraversalHandler
-
endNode
Description copied from interface:TraversalHandlerCalled during the traversal after an expression node children processing is finished.- Specified by:
endNodein interfaceTraversalHandler- Since:
- 1.1
-
objectNode
Description copied from interface:TraversalHandlerCalled during the traversal when a leaf non-expression node is encountered.- Specified by:
objectNodein interfaceTraversalHandler
-
parenthesisNeeded
-
appendLiteral
protected void appendLiteral(Object val, DbAttribute attr, Expression parentExpression) throws IOExceptionDescription copied from class:QueryAssemblerHelperAppends SQL code to the query buffer to handlevalas a parameter to the PreparedStatement being built. Addsvalinto QueryAssembler parameter list.If
valis null, "NULL" is appended to the query.If
valis a DataObject, its primary key value is used as a parameter. Only objects with a single column primary key can be used.- Overrides:
appendLiteralin classQueryAssemblerHelper- Parameters:
val- object that should be appended as a literal to the query. Must be of one of "standard JDBC" types, null or a DataObject.attr- DbAttribute that has information on what type of parameter is being appended.- Throws:
IOException
-
processRelTermination
Description copied from class:QueryAssemblerHelperHandles 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 expression for the source foreign key is added.- Overrides:
processRelTerminationin classQueryAssemblerHelper
-
appendFunction
Append function name to result SQL Override this method to rename or skip function if generic name isn't supported on target DB.- Since:
- 4.0
-
appendExtractFunction
Special case for extract date/time parts functions as they have many variants- Since:
- 4.0
-
appendFunctionArg
protected void appendFunctionArg(Object value, ASTFunctionCall functionExpression) throws IOExceptionAppend scalar argument of a function call Used only for values stored in ASTScalar other expressions appended in objectNode() method- Throws:
IOException- Since:
- 4.0
-
appendFunctionArgDivider
Append divider between function arguments. In overriding methods can be replaced e.g. for " || " for CONCAT operation- Since:
- 4.0
-
clearLastFunctionArgDivider
Clear last divider as we currently don't now position of argument until parent element is ended.- Since:
- 4.0
-