com.ibm.websphere.query.callbacks
Class SqlSelectQueryCallback

java.lang.Object
  extended by com.ibm.websphere.query.callbacks.SqlSelectQueryCallback
All Implemented Interfaces:
ISelectQueryCallback, java.io.Serializable
Direct Known Subclasses:
CloudscapeSqlSelectQueryCallback, DB2SqlSelectQueryCallback, OracleSqlSelectQueryCallback

public class SqlSelectQueryCallback
extends java.lang.Object
implements ISelectQueryCallback

The SqlSelectQueryCallback class is a query builder callback for SQL. It provides attributes mapping and query syntax conversion for developers to build meaningful SQL query strings.

It implments the ISelectQueryCallback interface so it can be used whenever an ISelectQueryCallback is needed.

This class has a hash table that contains SQL attributes mapping. When building an attribute string, the hash table is looked up to perform an attribute conversion. It is also used to convert multi-value conditions such as MVALL into sub-query strings.

See Also:
Serialized Form

Field Summary
static java.util.Set MULTIVALUE_SINGLEOPERAND_OPERATOR_SET
           
protected  java.util.Map objectMapping
           
static java.util.Map OPERATOR_MAP
           
protected  java.util.Map propertyColumnMap
           
protected  java.util.Map propertyTypeMap
           
static java.util.Set SINGLEOPERAND_NONNULL_OPERATOR_SET
           
static java.lang.String SQL_QUERY_AND
           
static java.lang.String SQL_QUERY_ARITHMETIC_ADD
           
static java.lang.String SQL_QUERY_ARITHMETIC_DIVIDE
           
static java.lang.String SQL_QUERY_ARITHMETIC_MULTIPLY
           
static java.lang.String SQL_QUERY_ARITHMETIC_SUBTRACT
           
static java.lang.String SQL_QUERY_BTW
           
static java.lang.String SQL_QUERY_COMMA
           
static java.lang.String SQL_QUERY_CONDITIONHEAD
           
static java.lang.String SQL_QUERY_CONDITIONTAIL
           
static java.lang.String SQL_QUERY_DELETE
           
static java.lang.String SQL_QUERY_DOT
           
static java.lang.String SQL_QUERY_EQ
           
static java.lang.String SQL_QUERY_FROM
           
static java.lang.String SQL_QUERY_GEQ
           
static java.lang.String SQL_QUERY_GT
           
static java.lang.String SQL_QUERY_IN
           
static java.lang.String SQL_QUERY_IS
           
static java.lang.String SQL_QUERY_ISN
           
static java.lang.String SQL_QUERY_ISNNULL
           
static java.lang.String SQL_QUERY_ISNULL
           
static java.lang.String SQL_QUERY_LEFTPAREN
           
static java.lang.String SQL_QUERY_LEQ
           
static java.lang.String SQL_QUERY_LIKE
           
static java.lang.String SQL_QUERY_LOWER
           
static java.lang.String SQL_QUERY_LT
           
static java.lang.String SQL_QUERY_MVALL
           
static java.lang.String SQL_QUERY_MVANY
           
static java.lang.String SQL_QUERY_NEQ
           
static java.lang.String SQL_QUERY_NOT_LIKE
           
static java.lang.String SQL_QUERY_NULL
           
static java.lang.String SQL_QUERY_OR
           
static java.lang.String SQL_QUERY_ORDERBYASC
           
static java.lang.String SQL_QUERY_ORDERBYASIS
           
static java.lang.String SQL_QUERY_ORDERBYDES
           
static java.lang.String SQL_QUERY_ORDERBYEXPSEP
           
static java.lang.String SQL_QUERY_ORDERBYHEAD
           
static java.lang.String SQL_QUERY_ORDERBYRANDOM
           
static java.lang.String SQL_QUERY_ORDERBYTAIL
           
static java.lang.String SQL_QUERY_PREDICATEHEAD
           
static java.lang.String SQL_QUERY_PREDICATETAIL
           
static java.lang.String SQL_QUERY_RIGHTPAREN
           
static java.lang.String SQL_QUERY_SELECT
           
static java.lang.String SQL_QUERY_SELECT_ALL
           
static java.lang.String SQL_QUERY_SPACE
           
static java.lang.String SQL_QUERY_SPACEAND
           
static java.lang.String SQL_QUERY_SPACEOR
           
static java.lang.String SQL_QUERY_STRINGSEP
           
static java.lang.String SQL_QUERY_UPPER
           
static java.lang.String SQL_QUERY_WHERE
           
static java.lang.String SQL_QUERY_WHERETAIL
           
static java.lang.String SQL_QUERY_WILDCARD
           
 
Fields inherited from interface com.ibm.websphere.query.base.ISelectQueryCallback
JOIN_CONDITIONS, JOIN_TABLES, JOINS, LAST_TABLE_ALIAS_INTEGER, MULTIVALUE_PROPERTY_NAMES, NAME_MAPPING, PREDICATE_IS_NULL, SELECT_ATTRIBUTES, TABLE_MAP, TABLE_NAME, TYPE_MAPPING
 
Constructor Summary
SqlSelectQueryCallback()
          Creates a new SqlSelectQueryCallback instance with the given attribute and type mappings.
SqlSelectQueryCallback(java.util.Hashtable nameMapping)
           
SqlSelectQueryCallback(java.util.Map propertyColumnMap, java.util.Map propertyTypeMap)
           
SqlSelectQueryCallback(java.util.Map propertyColumnMap, java.util.Map propertyTypeMap, java.util.Map objectMapping)
           
 
Method Summary
 java.lang.String buildArithmeticCondition(IArithmeticCondition arithmeticCondition)
          Returns the string representation for the given operator.
 void buildArithmeticCondition(IArithmeticCondition arithmeticCondition, java.lang.StringBuffer sb)
           
 java.lang.String buildAttribute(IAttribute attribute)
          Returns the SQL attribute string for the given attribute.
 void buildAttribute(IAttribute attribute, java.lang.StringBuffer sb)
          Appends the string representation of the specified attribute to the specified string buffer.
 java.lang.String buildCondition(ICondition condition)
          Returns the SQL condition string for the given condition.
 void buildCondition(ICondition condition, java.lang.StringBuffer sb)
           
 void buildFrom(IFrom from, java.lang.StringBuffer sb)
          Returns the string representation for the given from.
 void buildFrom(ISelectQuery selectQuery, java.lang.StringBuffer sb)
          Returns the string representation for the given from.
 java.lang.String buildFunction(IFunction function)
          Returns the SQL function string for the given function.
 void buildFunction(IFunction function, java.lang.StringBuffer sb)
           
protected  void buildInnerSelect(ISelectQuery table, java.lang.StringBuffer sb)
           
 void buildJoin(IJoin join, java.lang.StringBuffer sb)
          Returns the string representation for the given join.
 java.lang.String buildLimit(ILimit limit)
          Returns the string representation for the given limit clause.
 void buildLimit(ILimit limit, java.lang.StringBuffer sb)
           
 java.lang.String buildLimit(ISelectQuery selectQuery)
          Returns the string representation for the limit part of the given select query.
 void buildLimit(ISelectQuery selectQuery, java.lang.StringBuffer sb)
           
protected  void buildMultiValueJoins(java.util.Set multiValuePropertyNames, java.lang.StringBuffer sb)
           
 java.lang.String buildOperator(IOperator operator)
          Returns the SQL operator string for the given operator.
 void buildOperator(IOperator operator, java.lang.StringBuffer sb)
           
 java.lang.String buildOrderBy(IOrderBy orderBy)
          Returns the SQL order by string for the given order by object.
 void buildOrderBy(IOrderBy orderBy, java.lang.StringBuffer sb)
           
 java.lang.String buildOrderBy(ISelectQuery selectQuery)
          Returns the SQL order by string for the given select query.
 void buildOrderBy(ISelectQuery selectQuery, java.lang.StringBuffer sb)
           
 java.lang.String buildOrderByExpression(IOrderByExpression orderByExpression)
          Returns the SQL order by expression string for the given order by expression.
 void buildOrderByExpression(IOrderByExpression orderByExpression, java.lang.StringBuffer sb)
           
 java.lang.String buildPredicate(IPredicate predicate)
          Returns the string representation for the given predicate.
 void buildPredicate(IPredicate predicate, java.lang.StringBuffer sb)
           
 java.lang.String buildPredicate(IQuery query)
          Returns the string representation for the predicate part of the given query.
 void buildPredicate(IQuery query, java.lang.StringBuffer sb)
           
 java.lang.String buildQuery(IQuery query)
          Returns the SQL query string for the given query.
 void buildSelect(ISelectQuery selectQuery, java.lang.StringBuffer sb)
           
 void buildSelect(ISelect select, java.lang.StringBuffer sb)
          Returns the string representation for the given select.
 java.lang.String buildSelectQuery(ISelectQuery selectQuery)
          Returns the SQL select query string for the given select query.
 void buildSelectQuery(ISelectQuery selectQuery, java.lang.StringBuffer sb)
           
protected  void buildSMVCondition(ICondition condition, java.lang.StringBuffer sb)
          Returns the SQL condition string for the given condition that involves a multi-value left operand and a single-value operator.
 void buildTable(ITable table, java.lang.StringBuffer sb)
          Returns the string representation for the given table.
 java.lang.String buildValue(IValue value)
          Returns the SQL value string for the given value.
 void buildValue(IValue value, java.lang.StringBuffer sb)
           
protected  java.util.Set getMultiValuePropertyNameSet()
           
 java.util.Map getNameMapping(java.util.Map metadata)
           
 java.lang.String getNullCast()
           
protected  java.lang.String getTableAlias(java.lang.String tableName)
           
protected  java.lang.String getTableName()
           
 java.util.Map getTypeMapping(java.util.Map metadata)
           
protected  boolean isMultiValueAttribute(IAttribute attribute)
          Returns true if the given attribute is a multi-value attribute.
 java.lang.String makeQuerySafeValue(java.lang.String myValueString)
          Returns a new instance of the specified string with any instances of "'" double quoted.
protected  void processMvAll(ILeftOperand leftOperand, IRightOperand[] rightOperands, java.lang.StringBuffer sb)
          Returns the SQL condition string for operator "MVALL" in conjunction with the given left operand and right operands.
protected  void processMvAny(ILeftOperand leftOperand, IRightOperand[] rightOperands, java.lang.StringBuffer sb)
          Returns the SQL condition string for operator "MVANY" in conjunction with the given left operand and right operands.
protected  void processSMVBetween(ICondition condition, java.lang.StringBuffer sb)
          Returns the SQL condition string for the given condition that involves a multi-value left operand, a "BTW" operator, and two right operands.
protected  void processSMVIn(ICondition condition, java.lang.StringBuffer sb)
          Returns the SQL condition string for the given condition that involves a multi-value left operand, an "IN" operator, and multiple right operands.
protected  void processSMVSingle(ICondition condition, java.lang.StringBuffer sb)
          Returns the SQL condition string for the given condition that involves a multi-value left operand, a single-value operator, and a single right operand.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SQL_QUERY_SPACE

public static final java.lang.String SQL_QUERY_SPACE
See Also:
Constant Field Values

SQL_QUERY_STRINGSEP

public static final java.lang.String SQL_QUERY_STRINGSEP
See Also:
Constant Field Values

SQL_QUERY_LEFTPAREN

public static final java.lang.String SQL_QUERY_LEFTPAREN
See Also:
Constant Field Values

SQL_QUERY_RIGHTPAREN

public static final java.lang.String SQL_QUERY_RIGHTPAREN
See Also:
Constant Field Values

SQL_QUERY_COMMA

public static final java.lang.String SQL_QUERY_COMMA
See Also:
Constant Field Values

SQL_QUERY_WHERETAIL

public static final java.lang.String SQL_QUERY_WHERETAIL
See Also:
Constant Field Values

SQL_QUERY_CONDITIONHEAD

public static final java.lang.String SQL_QUERY_CONDITIONHEAD
See Also:
Constant Field Values

SQL_QUERY_CONDITIONTAIL

public static final java.lang.String SQL_QUERY_CONDITIONTAIL
See Also:
Constant Field Values

SQL_QUERY_WILDCARD

public static final java.lang.String SQL_QUERY_WILDCARD
See Also:
Constant Field Values

SQL_QUERY_DOT

public static final java.lang.String SQL_QUERY_DOT
See Also:
Constant Field Values

SQL_QUERY_PREDICATEHEAD

public static final java.lang.String SQL_QUERY_PREDICATEHEAD
See Also:
Constant Field Values

SQL_QUERY_PREDICATETAIL

public static final java.lang.String SQL_QUERY_PREDICATETAIL
See Also:
Constant Field Values

SQL_QUERY_AND

public static final java.lang.String SQL_QUERY_AND
See Also:
Constant Field Values

SQL_QUERY_SPACEAND

public static final java.lang.String SQL_QUERY_SPACEAND
See Also:
Constant Field Values

SQL_QUERY_OR

public static final java.lang.String SQL_QUERY_OR
See Also:
Constant Field Values

SQL_QUERY_SPACEOR

public static final java.lang.String SQL_QUERY_SPACEOR
See Also:
Constant Field Values

SQL_QUERY_EQ

public static final java.lang.String SQL_QUERY_EQ
See Also:
Constant Field Values

SQL_QUERY_NEQ

public static final java.lang.String SQL_QUERY_NEQ
See Also:
Constant Field Values

SQL_QUERY_LEQ

public static final java.lang.String SQL_QUERY_LEQ
See Also:
Constant Field Values

SQL_QUERY_LT

public static final java.lang.String SQL_QUERY_LT
See Also:
Constant Field Values

SQL_QUERY_GEQ

public static final java.lang.String SQL_QUERY_GEQ
See Also:
Constant Field Values

SQL_QUERY_GT

public static final java.lang.String SQL_QUERY_GT
See Also:
Constant Field Values

SQL_QUERY_BTW

public static final java.lang.String SQL_QUERY_BTW
See Also:
Constant Field Values

SQL_QUERY_IN

public static final java.lang.String SQL_QUERY_IN
See Also:
Constant Field Values

SQL_QUERY_LIKE

public static final java.lang.String SQL_QUERY_LIKE
See Also:
Constant Field Values

SQL_QUERY_NOT_LIKE

public static final java.lang.String SQL_QUERY_NOT_LIKE
See Also:
Constant Field Values

SQL_QUERY_IS

public static final java.lang.String SQL_QUERY_IS
See Also:
Constant Field Values

SQL_QUERY_ISN

public static final java.lang.String SQL_QUERY_ISN
See Also:
Constant Field Values

SQL_QUERY_NULL

public static final java.lang.String SQL_QUERY_NULL
See Also:
Constant Field Values

SQL_QUERY_ISNULL

public static final java.lang.String SQL_QUERY_ISNULL
See Also:
Constant Field Values

SQL_QUERY_ISNNULL

public static final java.lang.String SQL_QUERY_ISNNULL
See Also:
Constant Field Values

SQL_QUERY_ARITHMETIC_ADD

public static final java.lang.String SQL_QUERY_ARITHMETIC_ADD
See Also:
Constant Field Values

SQL_QUERY_ARITHMETIC_SUBTRACT

public static final java.lang.String SQL_QUERY_ARITHMETIC_SUBTRACT
See Also:
Constant Field Values

SQL_QUERY_ARITHMETIC_MULTIPLY

public static final java.lang.String SQL_QUERY_ARITHMETIC_MULTIPLY
See Also:
Constant Field Values

SQL_QUERY_ARITHMETIC_DIVIDE

public static final java.lang.String SQL_QUERY_ARITHMETIC_DIVIDE
See Also:
Constant Field Values

SQL_QUERY_UPPER

public static final java.lang.String SQL_QUERY_UPPER
See Also:
Constant Field Values

SQL_QUERY_LOWER

public static final java.lang.String SQL_QUERY_LOWER
See Also:
Constant Field Values

SQL_QUERY_SELECT

public static final java.lang.String SQL_QUERY_SELECT
See Also:
Constant Field Values

SQL_QUERY_SELECT_ALL

public static final java.lang.String SQL_QUERY_SELECT_ALL
See Also:
Constant Field Values

SQL_QUERY_DELETE

public static final java.lang.String SQL_QUERY_DELETE
See Also:
Constant Field Values

SQL_QUERY_FROM

public static final java.lang.String SQL_QUERY_FROM
See Also:
Constant Field Values

SQL_QUERY_WHERE

public static final java.lang.String SQL_QUERY_WHERE
See Also:
Constant Field Values

SQL_QUERY_ORDERBYHEAD

public static final java.lang.String SQL_QUERY_ORDERBYHEAD
See Also:
Constant Field Values

SQL_QUERY_ORDERBYTAIL

public static final java.lang.String SQL_QUERY_ORDERBYTAIL
See Also:
Constant Field Values

SQL_QUERY_ORDERBYEXPSEP

public static final java.lang.String SQL_QUERY_ORDERBYEXPSEP
See Also:
Constant Field Values

SQL_QUERY_ORDERBYASIS

public static final java.lang.String SQL_QUERY_ORDERBYASIS
See Also:
Constant Field Values

SQL_QUERY_ORDERBYRANDOM

public static final java.lang.String SQL_QUERY_ORDERBYRANDOM
See Also:
Constant Field Values

SQL_QUERY_ORDERBYASC

public static final java.lang.String SQL_QUERY_ORDERBYASC
See Also:
Constant Field Values

SQL_QUERY_ORDERBYDES

public static final java.lang.String SQL_QUERY_ORDERBYDES
See Also:
Constant Field Values

SQL_QUERY_MVANY

public static final java.lang.String SQL_QUERY_MVANY
See Also:
Constant Field Values

SQL_QUERY_MVALL

public static final java.lang.String SQL_QUERY_MVALL
See Also:
Constant Field Values

OPERATOR_MAP

public static final java.util.Map OPERATOR_MAP

MULTIVALUE_SINGLEOPERAND_OPERATOR_SET

public static final java.util.Set MULTIVALUE_SINGLEOPERAND_OPERATOR_SET

SINGLEOPERAND_NONNULL_OPERATOR_SET

public static final java.util.Set SINGLEOPERAND_NONNULL_OPERATOR_SET

propertyColumnMap

protected java.util.Map propertyColumnMap

propertyTypeMap

protected java.util.Map propertyTypeMap

objectMapping

protected java.util.Map objectMapping
Constructor Detail

SqlSelectQueryCallback

public SqlSelectQueryCallback()
Creates a new SqlSelectQueryCallback instance with the given attribute and type mappings.


SqlSelectQueryCallback

public SqlSelectQueryCallback(java.util.Hashtable nameMapping)

SqlSelectQueryCallback

public SqlSelectQueryCallback(java.util.Map propertyColumnMap,
                              java.util.Map propertyTypeMap)

SqlSelectQueryCallback

public SqlSelectQueryCallback(java.util.Map propertyColumnMap,
                              java.util.Map propertyTypeMap,
                              java.util.Map objectMapping)
Method Detail

buildAttribute

public java.lang.String buildAttribute(IAttribute attribute)
                                throws QueryException

Returns the SQL attribute string for the given attribute.

SQL table column name is returned if the attribute mapping contains an entry whose key matches the attribute name.

Specified by:
buildAttribute in interface ISelectQueryCallback
Throws:
QueryException

buildAttribute

public void buildAttribute(IAttribute attribute,
                           java.lang.StringBuffer sb)
                    throws QueryException
Appends the string representation of the specified attribute to the specified string buffer. If the attribute mapping contains an entry whose key matches the attribute name then the SQL table column name is appended. If the attribute represents a join then the string representation of the join is expanded and appended. If neither of these cases is true then that attribute name is appended as is.

Specified by:
buildAttribute in interface ISelectQueryCallback
Parameters:
attribute - the attribute to expand
sb - the string buffer to append to
Throws:
QueryException

buildCondition

public java.lang.String buildCondition(ICondition condition)
                                throws QueryException

Returns the SQL condition string for the given condition.

This method defines string generation for conditions with all possible operators supported in SQL. Note that the left operand is checked for multiplicity first because single-value operators have unique meanings for SQL if the left operand is a multi-value attribute.

Specified by:
buildCondition in interface ISelectQueryCallback
Throws:
QueryException

buildCondition

public void buildCondition(ICondition condition,
                           java.lang.StringBuffer sb)
                    throws QueryException
Specified by:
buildCondition in interface ISelectQueryCallback
Throws:
QueryException

getMultiValuePropertyNameSet

protected java.util.Set getMultiValuePropertyNameSet()
Returns:

buildFunction

public java.lang.String buildFunction(IFunction function)
                               throws QueryException

Returns the SQL function string for the given function.

This method defines string generation for all possible functions supported in SQL.

Specified by:
buildFunction in interface ISelectQueryCallback
Throws:
QueryException

buildFunction

public void buildFunction(IFunction function,
                          java.lang.StringBuffer sb)
                   throws QueryException
Specified by:
buildFunction in interface ISelectQueryCallback
Throws:
QueryException

buildOperator

public java.lang.String buildOperator(IOperator operator)
                               throws QueryException

Returns the SQL operator string for the given operator.

This method defines string generation for all possible operators supported in SQL.

Specified by:
buildOperator in interface ISelectQueryCallback
Throws:
QueryException

buildOperator

public void buildOperator(IOperator operator,
                          java.lang.StringBuffer sb)
                   throws QueryException
Specified by:
buildOperator in interface ISelectQueryCallback
Throws:
QueryException

buildOrderBy

public java.lang.String buildOrderBy(IOrderBy orderBy)
                              throws QueryException

Returns the SQL order by string for the given order by object.

This method iterates through the order by expressions in the order by object to generate the order by string in SQL.

Specified by:
buildOrderBy in interface ISelectQueryCallback
Throws:
QueryException

buildOrderBy

public void buildOrderBy(IOrderBy orderBy,
                         java.lang.StringBuffer sb)
                  throws QueryException
Specified by:
buildOrderBy in interface ISelectQueryCallback
Throws:
QueryException

buildOrderBy

public java.lang.String buildOrderBy(ISelectQuery selectQuery)
                              throws QueryException

Returns the SQL order by string for the given select query.

This method uses the order by in the select query to generate the order by string in SQL.

Specified by:
buildOrderBy in interface ISelectQueryCallback
Throws:
QueryException

buildOrderBy

public void buildOrderBy(ISelectQuery selectQuery,
                         java.lang.StringBuffer sb)
                  throws QueryException
Specified by:
buildOrderBy in interface ISelectQueryCallback
Throws:
QueryException

buildOrderByExpression

public java.lang.String buildOrderByExpression(IOrderByExpression orderByExpression)
                                        throws QueryException

Returns the SQL order by expression string for the given order by expression.

This method uses the order by element and operator in the order by expression to generate the order by expression string in SQL.

Specified by:
buildOrderByExpression in interface ISelectQueryCallback
Throws:
QueryException

buildOrderByExpression

public void buildOrderByExpression(IOrderByExpression orderByExpression,
                                   java.lang.StringBuffer sb)
                            throws QueryException
Specified by:
buildOrderByExpression in interface ISelectQueryCallback
Throws:
QueryException

buildPredicate

public java.lang.String buildPredicate(IPredicate predicate)
                                throws QueryException
Description copied from interface: ISelectQueryCallback
Returns the string representation for the given predicate. Domain specific predicate syntax can be applied here to generate meaningful strings.

Specified by:
buildPredicate in interface ISelectQueryCallback
Throws:
QueryException

buildPredicate

public void buildPredicate(IPredicate predicate,
                           java.lang.StringBuffer sb)
                    throws QueryException
Specified by:
buildPredicate in interface ISelectQueryCallback
Throws:
QueryException

buildPredicate

public java.lang.String buildPredicate(IQuery query)
                                throws QueryException
Description copied from interface: ISelectQueryCallback
Returns the string representation for the predicate part of the given query. Domain specific predicate syntax can be applied here to generate meaningful strings.

Specified by:
buildPredicate in interface ISelectQueryCallback
Throws:
QueryException

buildPredicate

public void buildPredicate(IQuery query,
                           java.lang.StringBuffer sb)
                    throws QueryException
Specified by:
buildPredicate in interface ISelectQueryCallback
Throws:
QueryException

buildQuery

public java.lang.String buildQuery(IQuery query)
                            throws QueryException

Returns the SQL query string for the given query.

This method calls buildPredicate() to generate the query string in SQL.

Specified by:
buildQuery in interface ISelectQueryCallback
Throws:
QueryException

buildSelectQuery

public java.lang.String buildSelectQuery(ISelectQuery selectQuery)
                                  throws QueryException

Returns the SQL select query string for the given select query.

This method calls buildPredicate() and buildOrderBy() to generate the select query string in SQL.

Specified by:
buildSelectQuery in interface ISelectQueryCallback
Throws:
QueryException

buildSelectQuery

public void buildSelectQuery(ISelectQuery selectQuery,
                             java.lang.StringBuffer sb)
                      throws QueryException
Specified by:
buildSelectQuery in interface ISelectQueryCallback
Throws:
QueryException

buildFrom

public void buildFrom(ISelectQuery selectQuery,
                      java.lang.StringBuffer sb)
               throws QueryException
Description copied from interface: ISelectQueryCallback
Returns the string representation for the given from.

Specified by:
buildFrom in interface ISelectQueryCallback
Throws:
QueryException

buildMultiValueJoins

protected void buildMultiValueJoins(java.util.Set multiValuePropertyNames,
                                    java.lang.StringBuffer sb)
                             throws QueryException
Throws:
QueryException

buildSelect

public void buildSelect(ISelectQuery selectQuery,
                        java.lang.StringBuffer sb)
                 throws QueryException
Throws:
QueryException

buildFrom

public void buildFrom(IFrom from,
                      java.lang.StringBuffer sb)
               throws QueryException
Description copied from interface: ISelectQueryCallback
Returns the string representation for the given from.

Specified by:
buildFrom in interface ISelectQueryCallback
Throws:
QueryException

buildInnerSelect

protected void buildInnerSelect(ISelectQuery table,
                                java.lang.StringBuffer sb)
                         throws QueryException
Throws:
QueryException

buildJoin

public void buildJoin(IJoin join,
                      java.lang.StringBuffer sb)
               throws QueryException
Description copied from interface: ISelectQueryCallback
Returns the string representation for the given join.

Specified by:
buildJoin in interface ISelectQueryCallback
Throws:
QueryException

buildTable

public void buildTable(ITable table,
                       java.lang.StringBuffer sb)
                throws QueryException
Description copied from interface: ISelectQueryCallback
Returns the string representation for the given table.

Specified by:
buildTable in interface ISelectQueryCallback
Throws:
QueryException

buildSelect

public void buildSelect(ISelect select,
                        java.lang.StringBuffer sb)
                 throws QueryException
Description copied from interface: ISelectQueryCallback
Returns the string representation for the given select.

Specified by:
buildSelect in interface ISelectQueryCallback
Throws:
QueryException

buildSMVCondition

protected void buildSMVCondition(ICondition condition,
                                 java.lang.StringBuffer sb)
                          throws QueryException

Returns the SQL condition string for the given condition that involves a multi-value left operand and a single-value operator.

This method calls processSMVSingle(), or processSMVBetween(), or processSMVIn to generate the condition query string in SQL.

Throws:
QueryException

buildValue

public java.lang.String buildValue(IValue value)
                            throws QueryException

Returns the SQL value string for the given value.

This method generates the value string in SQL based on the data type.

Specified by:
buildValue in interface ISelectQueryCallback
Throws:
QueryException

buildValue

public void buildValue(IValue value,
                       java.lang.StringBuffer sb)
                throws QueryException
Specified by:
buildValue in interface ISelectQueryCallback
Throws:
QueryException

getNameMapping

public java.util.Map getNameMapping(java.util.Map metadata)

getTypeMapping

public java.util.Map getTypeMapping(java.util.Map metadata)

isMultiValueAttribute

protected boolean isMultiValueAttribute(IAttribute attribute)
Returns true if the given attribute is a multi-value attribute. False otherwise.


processMvAll

protected void processMvAll(ILeftOperand leftOperand,
                            IRightOperand[] rightOperands,
                            java.lang.StringBuffer sb)
                     throws QueryException

Returns the SQL condition string for operator "MVALL" in conjunction with the given left operand and right operands.

This method converts a MVALL condition into a sub query condition string in SQL. The left operand has to be a multi-value attribute.

Throws:
QueryException

processMvAny

protected void processMvAny(ILeftOperand leftOperand,
                            IRightOperand[] rightOperands,
                            java.lang.StringBuffer sb)
                     throws QueryException

Returns the SQL condition string for operator "MVANY" in conjunction with the given left operand and right operands.

This method converts a MVANY condition into a sub query condition string in SQL. The left operand has to be a multi-value attribute.

Throws:
QueryException

processSMVBetween

protected void processSMVBetween(ICondition condition,
                                 java.lang.StringBuffer sb)
                          throws QueryException

Returns the SQL condition string for the given condition that involves a multi-value left operand, a "BTW" operator, and two right operands.

This method converts a multi-value BTW condition into a sub query condition string in SQL. The left operand has to be a multi-value attribute.

Throws:
QueryException

processSMVIn

protected void processSMVIn(ICondition condition,
                            java.lang.StringBuffer sb)
                     throws QueryException

Returns the SQL condition string for the given condition that involves a multi-value left operand, an "IN" operator, and multiple right operands.

This method converts a multi-value IN condition into a sub query condition string in SQL. The left operand has to be a multi-value attribute.

Throws:
QueryException

processSMVSingle

protected void processSMVSingle(ICondition condition,
                                java.lang.StringBuffer sb)
                         throws QueryException

Returns the SQL condition string for the given condition that involves a multi-value left operand, a single-value operator, and a single right operand.

This method converts a multi-value condition that takes a single right operand into a sub query condition string in SQL. The left operand has to be a multi-value attribute.

Throws:
QueryException

makeQuerySafeValue

public java.lang.String makeQuerySafeValue(java.lang.String myValueString)
Returns a new instance of the specified string with any instances of "'" double quoted.

Parameters:
myValueString - the string to sanitize
Returns:
a new instance of the specified string with any instances of "'" double quoted.

buildArithmeticCondition

public java.lang.String buildArithmeticCondition(IArithmeticCondition arithmeticCondition)
                                          throws QueryException
Description copied from interface: ISelectQueryCallback
Returns the string representation for the given operator. Domain specific operator syntax can be applied here to generate meaningful strings.

Specified by:
buildArithmeticCondition in interface ISelectQueryCallback
Throws:
QueryException
See Also:
ISelectQueryCallback.buildArithmeticCondition(IArithmeticCondition)

buildArithmeticCondition

public void buildArithmeticCondition(IArithmeticCondition arithmeticCondition,
                                     java.lang.StringBuffer sb)
                              throws QueryException
Specified by:
buildArithmeticCondition in interface ISelectQueryCallback
Throws:
QueryException

getNullCast

public java.lang.String getNullCast()

buildLimit

public java.lang.String buildLimit(ILimit limit)
                            throws QueryException
Description copied from interface: ISelectQueryCallback
Returns the string representation for the given limit clause. Domain specific limit syntax can be applied here to generate meaningful strings.

Specified by:
buildLimit in interface ISelectQueryCallback
Throws:
QueryException
See Also:
ISelectQueryCallback.buildLimit(ILimit)

buildLimit

public void buildLimit(ILimit limit,
                       java.lang.StringBuffer sb)
                throws QueryException
Specified by:
buildLimit in interface ISelectQueryCallback
Throws:
QueryException

buildLimit

public java.lang.String buildLimit(ISelectQuery selectQuery)
                            throws QueryException
Description copied from interface: ISelectQueryCallback
Returns the string representation for the limit part of the given select query. Domain specific limit syntax can be applied here to generate meaningful strings.

Specified by:
buildLimit in interface ISelectQueryCallback
Throws:
QueryException
See Also:
ISelectQueryCallback.buildLimit(ISelectQuery)

buildLimit

public void buildLimit(ISelectQuery selectQuery,
                       java.lang.StringBuffer sb)
                throws QueryException
Specified by:
buildLimit in interface ISelectQueryCallback
Throws:
QueryException

getTableAlias

protected java.lang.String getTableAlias(java.lang.String tableName)

getTableName

protected java.lang.String getTableName()
                                 throws QueryException
Throws:
QueryException