Ontimize 5.2072EN

com.ontimize.db.handler
Class DefaultSQLStatementHandler

java.lang.Object
  extended bycom.ontimize.db.handler.DefaultSQLStatementHandler
All Implemented Interfaces:
SQLStatementHandler
Direct Known Subclasses:
HSQLDBSQLStatementHandler, MySQLSQLStatementHandler, OracleSQLStatementHandler, PostgresSQLStatementHandler, SQLServerSQLStatementHandler

public class DefaultSQLStatementHandler
extends java.lang.Object
implements SQLStatementHandler


Field Summary
protected  char[] CONFLICT_CHARS
           
protected  SQLStatementBuilder.SQLConditionValuesProcessor queryConditionsProcessor
           
protected  SQLStatementBuilder.SQLNameEval sqlNameEval
           
 boolean useAsInSubqueries
           
 
Constructor Summary
DefaultSQLStatementHandler()
           
 
Method Summary
 void addSpecialCharacters(char[] c)
          Adds characters to the list of special characters.
protected  void changeColumnNames(EntityResult result, java.util.List columnNames)
           
 boolean checkColumnName(java.lang.String columnName)
          Returns true if square brackets are necessary insert in this column name.
protected  java.lang.String createCountQuery(java.lang.String table)
           
 SQLStatementBuilder.SQLStatement createCountQuery(java.lang.String table, java.util.Hashtable conditions, java.util.Vector wildcards)
          Returns a SQLStatement class that stores the information needed to execute a query that obtains the number of query records
 SQLStatementBuilder.SQLStatement createDeleteQuery(java.lang.String table, java.util.Hashtable keysValues)
          Returns a SQLStatement class that stores the information needed to execute a delete query.
 SQLStatementBuilder.SQLStatement createInsertQuery(java.lang.String table, java.util.Hashtable attributes)
          Returns a SQLStatement class that stores the information needed to execute a insert query.
 SQLStatementBuilder.SQLStatement createJoinSelectQuery(java.lang.String principalTable, java.lang.String secondaryTable, java.util.Vector principalKeys, java.util.Vector secondaryKeys, java.util.Vector principalTableRequestedColumns, java.util.Vector secondaryTableRequestedColumns, java.util.Hashtable principalTableConditions, java.util.Hashtable secondaryTableConditions, java.util.Vector wildcards, java.util.Vector columnSorting, boolean forceDistinct)
          This class provides a implementation of the SQLConditionValuesProcessor interface.
 SQLStatementBuilder.SQLStatement createJoinSelectQuery(java.lang.String mainTable, java.lang.String secondaryTable, java.util.Vector mainKeys, java.util.Vector secondaryKeys, java.util.Vector mainTableRequestedColumns, java.util.Vector secondaryTableRequestedColumns, java.util.Hashtable mainTableConditions, java.util.Hashtable secondaryTableConditions, java.util.Vector wildcards, java.util.Vector columnSorting, boolean forceDistinct, boolean descending)
          Returns a SQLStatement class that stores the information needed to execute a select query against two table used a join.
protected  java.lang.String createQueryConditions(java.util.Hashtable conditions, java.util.Vector wildcard, java.util.Vector values)
          Returns the condition string for a SQL Statement.
protected  java.lang.String createQueryConditions(java.util.Hashtable conditions, java.util.Vector wildcardColumns, java.util.Vector values, boolean withWhere)
           
 java.lang.String createQueryConditionsWithoutWhere(java.util.Hashtable conditions, java.util.Vector wildcard, java.util.Vector values)
          Returns the condition string for a SQL Statement without WHERE clause in SQL.
protected  java.lang.String createSelectQuery(java.lang.String table, java.util.Vector askedColumns)
           
protected  java.lang.String createSelectQuery(java.lang.String table, java.util.Vector askedColumns, boolean forceDistinct)
           
 SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table, java.util.Vector requestedColumns, java.util.Hashtable conditions, java.util.Vector wildcards)
          Returns a SQLStatement class that stores the information needed to execute a select query.
 SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table, java.util.Vector requestedColumns, java.util.Hashtable conditions, java.util.Vector wildcards, java.util.Vector columnSorting)
          Returns a SQLStatement class that stores the information needed to execute a select query.
 SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table, java.util.Vector requestedColumns, java.util.Hashtable conditions, java.util.Vector wildcards, java.util.Vector columnSorting, boolean descending)
          Returns a SQLStatement class that stores the information needed to execute a select query.
 SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table, java.util.Vector requestedColumns, java.util.Hashtable conditions, java.util.Vector wildcards, java.util.Vector columnSorting, boolean descending, boolean forceDistinct)
          Returns a SQLStatement class that stores the information needed to execute a select query.
 SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table, java.util.Vector requestedColumns, java.util.Hashtable conditions, java.util.Vector wildcards, java.util.Vector columnSorting, int recordCount)
          Returns a SQLStatement class that stores the information needed to execute a select query.
 SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table, java.util.Vector requestedColumns, java.util.Hashtable conditions, java.util.Vector wildcards, java.util.Vector columnSorting, int recordCount, boolean descending)
          Returns a SQLStatement class that stores the information needed to execute a select query.
 SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table, java.util.Vector requestedColumns, java.util.Hashtable conditions, java.util.Vector wildcards, java.util.Vector columnSorting, int recordCount, boolean descending, boolean forceDistinct)
          Returns a SQLStatement class that stores the information needed to execute a select query.
 SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table, java.util.Vector requestedColumns, java.util.Hashtable conditions, java.util.Vector wildcards, java.util.Vector columnSorting, int recordCount, int offset)
           
 SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table, java.util.Vector requestedColumns, java.util.Hashtable conditions, java.util.Vector wildcards, java.util.Vector columnSorting, int recordCount, int offset, boolean descending)
           
 SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table, java.util.Vector requestedColumns, java.util.Hashtable conditions, java.util.Vector wildcards, java.util.Vector columnSorting, int recordCount, int offset, boolean descending, boolean forceDistinct)
           
protected  java.lang.String createSortStatement(java.util.Vector sortColumns)
           
protected  java.lang.String createSortStatement(java.util.Vector sortColumns, boolean descending)
           
 SQLStatementBuilder.SQLStatement createUpdateQuery(java.lang.String table, java.util.Hashtable attributesValues, java.util.Hashtable keysValues)
          Returns a SQLStatement class that stores the information needed to execute a update query.
protected  java.lang.String[] getColumnNames(java.sql.ResultSetMetaData rsMetaData)
           
 SQLStatementBuilder.SQLConditionValuesProcessor getQueryConditionsProcessor()
          Returns a instance of SQLConditionValuesProcessor that be used in this class to create the condition string
 SQLStatementBuilder.SQLNameEval getSQLNameEval()
           
protected  DBFunctionName hasIsolationFunction(java.util.Vector requestedColumns)
           
 boolean isDelimited()
           
 boolean isPageable()
           
 boolean isUseAsInSubqueries()
           
 java.lang.String qualify(java.lang.String col, java.lang.String table)
          Returns a String with the qualified name.
protected  java.lang.Object readBinaryStream(java.io.InputStream in)
          Reads an array of bytes from the stream in.
protected  java.lang.Object readCharacterStream(java.io.InputStream in)
          Returns a String containing the characters read from the stream in.
protected  java.lang.Object readCharacterStream(java.io.Reader in)
          Returns a String containing the characters read from the reader in.
 void resultSetToEntityResult(java.sql.ResultSet resultSet, EntityResult entityResult, int recordNumber, int offset, boolean delimited, java.util.List columnNames)
          Transforms a java.sql.ResultSet object into an Ontimize EntityResult.
 void resultSetToEntityResult(java.sql.ResultSet resultSet, EntityResult entityResult, java.util.List columnNames)
           
 void setSQLConditionValuesProcessor(SQLStatementBuilder.SQLConditionValuesProcessor processor)
          Sets the SQLConditionValuesProcessor to be used in SQLStatementBuilder
 void setSQLNameEval(SQLStatementBuilder.SQLNameEval eval)
           
 void setUseAsInSubqueries(boolean useAsInSubqueries)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queryConditionsProcessor

protected SQLStatementBuilder.SQLConditionValuesProcessor queryConditionsProcessor

sqlNameEval

protected SQLStatementBuilder.SQLNameEval sqlNameEval

CONFLICT_CHARS

protected char[] CONFLICT_CHARS

useAsInSubqueries

public boolean useAsInSubqueries
Constructor Detail

DefaultSQLStatementHandler

public DefaultSQLStatementHandler()
Method Detail

isUseAsInSubqueries

public boolean isUseAsInSubqueries()
Specified by:
isUseAsInSubqueries in interface SQLStatementHandler

setUseAsInSubqueries

public void setUseAsInSubqueries(boolean useAsInSubqueries)
Specified by:
setUseAsInSubqueries in interface SQLStatementHandler

setSQLConditionValuesProcessor

public void setSQLConditionValuesProcessor(SQLStatementBuilder.SQLConditionValuesProcessor processor)
Sets the SQLConditionValuesProcessor to be used in SQLStatementBuilder

Specified by:
setSQLConditionValuesProcessor in interface SQLStatementHandler
Parameters:
processor - the SQLConditionValuesProcessor instance that be used

createCountQuery

public SQLStatementBuilder.SQLStatement createCountQuery(java.lang.String table,
                                                         java.util.Hashtable conditions,
                                                         java.util.Vector wildcards)
Returns a SQLStatement class that stores the information needed to execute a query that obtains the number of query records

Specified by:
createCountQuery in interface SQLStatementHandler
Parameters:
table - name of the table the query is executed against
conditions - condition list used in the query
wildcards - column list that can use wildcards
Returns:
a SQLStatement class

createSelectQuery

public SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table,
                                                          java.util.Vector requestedColumns,
                                                          java.util.Hashtable conditions,
                                                          java.util.Vector wildcards)
Returns a SQLStatement class that stores the information needed to execute a select query.

Specified by:
createSelectQuery in interface SQLStatementHandler
Parameters:
table - name of the table the query is executed against
requestedColumns - a Vector specifying the requested column name in the query
conditions - condition list used to created the query
wildcards -
Returns:
a SQLStatement class
See Also:
SQLStatementBuilder.SQLStatement

createSelectQuery

public SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table,
                                                          java.util.Vector requestedColumns,
                                                          java.util.Hashtable conditions,
                                                          java.util.Vector wildcards,
                                                          java.util.Vector columnSorting,
                                                          int recordCount)
Returns a SQLStatement class that stores the information needed to execute a select query.

Specified by:
createSelectQuery in interface SQLStatementHandler
Parameters:
table - name of the table the query is executed against
requestedColumns - a Vector specifying the requested column name in the query
conditions - condition list used to created the query
wildcards - column list that can use wildcards
columnSorting - column list where query sorting is established
recordCount - number of records requested in the query
Returns:
a SQLStatement class
See Also:
SQLStatementBuilder.SQLStatement

createSelectQuery

public SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table,
                                                          java.util.Vector requestedColumns,
                                                          java.util.Hashtable conditions,
                                                          java.util.Vector wildcards,
                                                          java.util.Vector columnSorting,
                                                          int recordCount,
                                                          boolean descending)
Returns a SQLStatement class that stores the information needed to execute a select query.

Specified by:
createSelectQuery in interface SQLStatementHandler
Parameters:
table - name of the table the query is executed against
requestedColumns - a Vector specifying the requested column name in the query
conditions - condition list used to created the query
wildcards - column list that can use wildcards
columnSorting - column list where query sorting is established
recordCount - number of records requested in the query
descending - true if sorting should be descending
Returns:
a SQLStatement class
See Also:
SQLStatementBuilder.SQLStatement

createSelectQuery

public SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table,
                                                          java.util.Vector requestedColumns,
                                                          java.util.Hashtable conditions,
                                                          java.util.Vector wildcards,
                                                          java.util.Vector columnSorting,
                                                          int recordCount,
                                                          boolean descending,
                                                          boolean forceDistinct)
Returns a SQLStatement class that stores the information needed to execute a select query.

Specified by:
createSelectQuery in interface SQLStatementHandler
Parameters:
table - name of the table the query is executed against
requestedColumns - a Vector specifying the requested column name in the query
conditions - condition list used to created the query
wildcards - column list that can use wildcards
columnSorting - column list where query sorting is established
recordCount - number of records requested in the query
forceDistinct - true if query result cannot have duplicated records
descending - true if sorting should be descending
Returns:
a SQLStatement class
See Also:
SQLStatementBuilder.SQLStatement

createSelectQuery

public SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table,
                                                          java.util.Vector requestedColumns,
                                                          java.util.Hashtable conditions,
                                                          java.util.Vector wildcards,
                                                          java.util.Vector columnSorting,
                                                          int recordCount,
                                                          int offset)
Specified by:
createSelectQuery in interface SQLStatementHandler

createSelectQuery

public SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table,
                                                          java.util.Vector requestedColumns,
                                                          java.util.Hashtable conditions,
                                                          java.util.Vector wildcards,
                                                          java.util.Vector columnSorting,
                                                          int recordCount,
                                                          int offset,
                                                          boolean descending)
Specified by:
createSelectQuery in interface SQLStatementHandler

createSelectQuery

public SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table,
                                                          java.util.Vector requestedColumns,
                                                          java.util.Hashtable conditions,
                                                          java.util.Vector wildcards,
                                                          java.util.Vector columnSorting,
                                                          int recordCount,
                                                          int offset,
                                                          boolean descending,
                                                          boolean forceDistinct)
Specified by:
createSelectQuery in interface SQLStatementHandler

createSelectQuery

public SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table,
                                                          java.util.Vector requestedColumns,
                                                          java.util.Hashtable conditions,
                                                          java.util.Vector wildcards,
                                                          java.util.Vector columnSorting)
Returns a SQLStatement class that stores the information needed to execute a select query.

Specified by:
createSelectQuery in interface SQLStatementHandler
Parameters:
table - name of the table the query is executed against
requestedColumns - a Vector specifying the requested column name in the query
conditions - condition list used to created the query
wildcards - column list that can use wildcards
columnSorting - column list where query sorting is established
Returns:
a SQLStatement class
See Also:
SQLStatementBuilder.SQLStatement

createSelectQuery

public SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table,
                                                          java.util.Vector requestedColumns,
                                                          java.util.Hashtable conditions,
                                                          java.util.Vector wildcards,
                                                          java.util.Vector columnSorting,
                                                          boolean descending)
Returns a SQLStatement class that stores the information needed to execute a select query.

Specified by:
createSelectQuery in interface SQLStatementHandler
Parameters:
table - name of the table the query is executed against
requestedColumns - a Vector specifying the requested column name in the query
conditions - condition list used to created the query
wildcards - column list that can use wildcards
columnSorting - column list where query sorting is established
descending - true if sorting should be descending
Returns:
a SQLStatement class
See Also:
SQLStatementBuilder.SQLStatement

createSelectQuery

public SQLStatementBuilder.SQLStatement createSelectQuery(java.lang.String table,
                                                          java.util.Vector requestedColumns,
                                                          java.util.Hashtable conditions,
                                                          java.util.Vector wildcards,
                                                          java.util.Vector columnSorting,
                                                          boolean descending,
                                                          boolean forceDistinct)
Returns a SQLStatement class that stores the information needed to execute a select query.

Specified by:
createSelectQuery in interface SQLStatementHandler
Parameters:
table - name of the table the query is executed against
requestedColumns - a Vector specifying the requested column name in the query
conditions - condition list used to created the query
wildcards - column list that can use wildcards
columnSorting - column list where query sorting is established
forceDistinct - true if query result cannot have duplicated records
descending - true if sorting should be descending
Returns:
a SQLStatement class
See Also:
SQLStatementBuilder.SQLStatement

hasIsolationFunction

protected DBFunctionName hasIsolationFunction(java.util.Vector requestedColumns)

createSortStatement

protected java.lang.String createSortStatement(java.util.Vector sortColumns,
                                               boolean descending)

createSortStatement

protected java.lang.String createSortStatement(java.util.Vector sortColumns)

createCountQuery

protected java.lang.String createCountQuery(java.lang.String table)

createSelectQuery

protected java.lang.String createSelectQuery(java.lang.String table,
                                             java.util.Vector askedColumns,
                                             boolean forceDistinct)

createSelectQuery

protected java.lang.String createSelectQuery(java.lang.String table,
                                             java.util.Vector askedColumns)

createQueryConditions

protected java.lang.String createQueryConditions(java.util.Hashtable conditions,
                                                 java.util.Vector wildcardColumns,
                                                 java.util.Vector values,
                                                 boolean withWhere)

createQueryConditions

protected java.lang.String createQueryConditions(java.util.Hashtable conditions,
                                                 java.util.Vector wildcard,
                                                 java.util.Vector values)
Returns the condition string for a SQL Statement.

Parameters:
conditions - condition list that be using for create the string
wildcard - column list that can use wildcards
values - vector where the value of each processed conditions is stored
Returns:
a condition String

createQueryConditionsWithoutWhere

public java.lang.String createQueryConditionsWithoutWhere(java.util.Hashtable conditions,
                                                          java.util.Vector wildcard,
                                                          java.util.Vector values)
Returns the condition string for a SQL Statement without WHERE clause in SQL.

Specified by:
createQueryConditionsWithoutWhere in interface SQLStatementHandler
Parameters:
conditions - condition list that be using for create the string
wildcard - column list that can use wildcards
values - vector where the value of each processed conditions is stored
Returns:
a condition String

setSQLNameEval

public void setSQLNameEval(SQLStatementBuilder.SQLNameEval eval)
Specified by:
setSQLNameEval in interface SQLStatementHandler

getSQLNameEval

public SQLStatementBuilder.SQLNameEval getSQLNameEval()
Specified by:
getSQLNameEval in interface SQLStatementHandler

checkColumnName

public boolean checkColumnName(java.lang.String columnName)
Returns true if square brackets are necessary insert in this column name.

If the column name has a character of the special character list, it's necessary insert column name in square brackets.

Specified by:
checkColumnName in interface SQLStatementHandler
Returns:
true if square brackets are necessary insert in this column name.

createInsertQuery

public SQLStatementBuilder.SQLStatement createInsertQuery(java.lang.String table,
                                                          java.util.Hashtable attributes)
Returns a SQLStatement class that stores the information needed to execute a insert query.

Specified by:
createInsertQuery in interface SQLStatementHandler
Parameters:
table - name of the table the query is executed against
attributes - attributes a Hashtable specifying pairs of key-value corresponding to the attribute (or column of a table in a database) and the value that must be stored.
Returns:

createUpdateQuery

public SQLStatementBuilder.SQLStatement createUpdateQuery(java.lang.String table,
                                                          java.util.Hashtable attributesValues,
                                                          java.util.Hashtable keysValues)
Returns a SQLStatement class that stores the information needed to execute a update query.

Specified by:
createUpdateQuery in interface SQLStatementHandler
Parameters:
table - name of the table the update is executed against
attributesValues - attributesValues the data for updating the records to. The keys specify the attributes (or columns) and the values, the values for these columns.
keysValues - keysValues the conditions that the records to be updated must fulfill. The keys specify the attributes (or columns) and the values, the values for these columns.
Returns:
See Also:
SQLStatementBuilder.SQLStatement

createDeleteQuery

public SQLStatementBuilder.SQLStatement createDeleteQuery(java.lang.String table,
                                                          java.util.Hashtable keysValues)
Returns a SQLStatement class that stores the information needed to execute a delete query.

Specified by:
createDeleteQuery in interface SQLStatementHandler
Parameters:
table - name of the table the query is executed against
keysValues - the conditions that the records to be deleted must fulfill. The keys specify the attributes (or columns) and the values, the values for these columns.
Returns:

addSpecialCharacters

public void addSpecialCharacters(char[] c)
Adds characters to the list of special characters.

When the query is be created if a column name contains a character of the list this column name is inserted between parenthesis in the query.

Specified by:
addSpecialCharacters in interface SQLStatementHandler
Parameters:
c - a array with the new characters

createJoinSelectQuery

public SQLStatementBuilder.SQLStatement createJoinSelectQuery(java.lang.String principalTable,
                                                              java.lang.String secondaryTable,
                                                              java.util.Vector principalKeys,
                                                              java.util.Vector secondaryKeys,
                                                              java.util.Vector principalTableRequestedColumns,
                                                              java.util.Vector secondaryTableRequestedColumns,
                                                              java.util.Hashtable principalTableConditions,
                                                              java.util.Hashtable secondaryTableConditions,
                                                              java.util.Vector wildcards,
                                                              java.util.Vector columnSorting,
                                                              boolean forceDistinct)
This class provides a implementation of the SQLConditionValuesProcessor interface.

This class extends DefaultSQLConditionValuesProcessor and permits process complex conditions where condition key doesn't have to be the column of a table in a database. EXPRESSION_KEY is used as condition key to indicate which is a complex condition

Using classes that implements Expression, Field, Operator interfaces is necessary to define a complex condition. Each class that implements the Expression interface has three important parts. The left operand that can only be another expression or a class that implements Field interface The right operand that can be another expression or a value The operator that has to be a class that implement Operator interface

In the next examples the basic implementations have been used:

  Example for a simple expression:
  
  	Operator equalOperator=BasicOperator.EQUAL_OP;
  	Field field = new BasicField("columnName1");
  
  	Expression expression = new BasicExpression(field,equalOperator,"filterValue");
  	Hashtable conditions=new Hashtable();
  	conditions.put(ExtendedSQLConditionValuesProcessor.EXPRESSION_KEY,expression);
  
  Example for a complex expression:
  	Operator equalOperator=BasicOperator.EQUAL_OP;
  	Field field1 = new BasicField("columnName1");
  	Expression expression1 = new BasicExpression(field1,equalOperator,"filterValue");
  	
  	Field field2 = new BasicField("columnName2");
  	Expression expression2 = new BasicExpression(field2,BasicOperator.LESS,new Integer(10));
  
  	Expression totalExpression = new Expression(expression1,BasicOperator.AND,expression2);
  
  	Hashtable conditions=new Hashtable();
   	conditions.put(ExtendedSQLConditionValuesProcessor.EXPRESSION_KEY,totalExpression);
  

Specified by:
createJoinSelectQuery in interface SQLStatementHandler
See Also:
SQLStatementBuilder.Expression

qualify

public java.lang.String qualify(java.lang.String col,
                                java.lang.String table)
Returns a String with the qualified name.

This static methods creates a qualified name from the column name and the table name. The used pattern is table_name.column_name. If the table name or the column name has special characters, square brackets are used [table_name].[column_name]

Specified by:
qualify in interface SQLStatementHandler
Parameters:
col - a String with the column name
table - a String with the table name
Returns:
a String with the qualified name.

createJoinSelectQuery

public SQLStatementBuilder.SQLStatement createJoinSelectQuery(java.lang.String mainTable,
                                                              java.lang.String secondaryTable,
                                                              java.util.Vector mainKeys,
                                                              java.util.Vector secondaryKeys,
                                                              java.util.Vector mainTableRequestedColumns,
                                                              java.util.Vector secondaryTableRequestedColumns,
                                                              java.util.Hashtable mainTableConditions,
                                                              java.util.Hashtable secondaryTableConditions,
                                                              java.util.Vector wildcards,
                                                              java.util.Vector columnSorting,
                                                              boolean forceDistinct,
                                                              boolean descending)
Returns a SQLStatement class that stores the information needed to execute a select query against two table used a join.

Specified by:
createJoinSelectQuery in interface SQLStatementHandler
Parameters:
mainTable - name of the principal table the query is executed against
secondaryTable - name of the secondary table the query is executed against
mainKeys - a Vector specifying the column names of the principal table that be used to combine the two tables
secondaryKeys - a Vector specifying the column names of the secondary table that be used to combine the two tables
mainTableRequestedColumns - column list that be requested in the query from principal table
secondaryTableRequestedColumns - column list that be requested in the query from secondary table
mainTableConditions - a Hashtable specifying conditions that must comply the set of records returned from principal table
secondaryTableConditions - a Hashtable specifying conditions that must comply the set of records returned from secondary table
wildcards - column list which wildcards can be used in
columnSorting - column list where query sorting is established
forceDistinct - true if query result cannot have duplicated records
descending - true if sorting should be descending
Returns:
a SQLStatement class which stores the SQL Statement and the required values

getQueryConditionsProcessor

public SQLStatementBuilder.SQLConditionValuesProcessor getQueryConditionsProcessor()
Returns a instance of SQLConditionValuesProcessor that be used in this class to create the condition string

Specified by:
getQueryConditionsProcessor in interface SQLStatementHandler
Returns:
a SQLConditionValuesProcessor class

isPageable

public boolean isPageable()
Specified by:
isPageable in interface SQLStatementHandler

isDelimited

public boolean isDelimited()
Specified by:
isDelimited in interface SQLStatementHandler

resultSetToEntityResult

public void resultSetToEntityResult(java.sql.ResultSet resultSet,
                                    EntityResult entityResult,
                                    java.util.List columnNames)
                             throws java.lang.Exception
Specified by:
resultSetToEntityResult in interface SQLStatementHandler
Throws:
java.lang.Exception

resultSetToEntityResult

public void resultSetToEntityResult(java.sql.ResultSet resultSet,
                                    EntityResult entityResult,
                                    int recordNumber,
                                    int offset,
                                    boolean delimited,
                                    java.util.List columnNames)
                             throws java.lang.Exception
Transforms a java.sql.ResultSet object into an Ontimize EntityResult. The columns in the ResultSet are the keys in the EntityResult, and the values for the columns are stored in Vector objects corresponding to the keys in the EntityResult.

The following getxxxxx ResulSet methods are used for getting column data:

  • getBlob for BLOB SQLType
  • getClob for CLOB SQLType
  • getBinaryStream for VARBINARY or LOGVARBINARY SQLType
  • getAsciiStream for LONGVARCHAR SQLType
  • getObject for rest of SQLTypes

Specified by:
resultSetToEntityResult in interface SQLStatementHandler
Parameters:
resultSet - the source ResultSet
entityResult - the destination EntityResult. It has a Hashtable of Vectors structure.
recordNumber - Number of records to query
offset - number of the row where start
delimited - If delimited is true then all the resultSet must be queried into the EntityResult, because the original query that generated the ResultSet only returns the number of records specified in recordNumber. If delimited is false then this method only read the specified recordNumber from the ResultSet into the EntityResult
columnNames - Names of the columns to return in the EntityResult. If this parameter is null or empty then return exactly the same names in the ResultSet
Throws:
java.lang.Exception - if any error (database, etc.) occurs

changeColumnNames

protected void changeColumnNames(EntityResult result,
                                 java.util.List columnNames)

getColumnNames

protected java.lang.String[] getColumnNames(java.sql.ResultSetMetaData rsMetaData)
Parameters:
rsMetaData - Database metadata. See custom implementation at MySQLSQLStatementHandler.
Returns:
Column names.
Since:
5.2071EN-0.1

readCharacterStream

protected java.lang.Object readCharacterStream(java.io.InputStream in)
Returns a String containing the characters read from the stream in.

No character conversion is performed.

Parameters:
in -
Returns:
the characters contained in the stream or null if stream is empty

readCharacterStream

protected java.lang.Object readCharacterStream(java.io.Reader in)
Returns a String containing the characters read from the reader in.

No character conversion is performed.

Parameters:
in -
Returns:
the characters contained in the reader or null if stream is empty

readBinaryStream

protected java.lang.Object readBinaryStream(java.io.InputStream in)
Reads an array of bytes from the stream in.

Parameters:
in -
Returns:
a BytesBlock object containing the byte array or null if the stream is empty

Ontimize