public abstract class SQLStatementBuilder extends Object
SQLStatementBuilder class builds SQL statements
This class is used by every entity to build the SQL Statements needed to query the database.
| Modifier and Type | Class and Description |
|---|---|
static class |
SQLStatementBuilder.BasicExpression
Default implementation of
Expression interfaces. |
static class |
SQLStatementBuilder.BasicField
Default implementation of
Field interfaces. |
static class |
SQLStatementBuilder.BasicOperator
Default implementation of
Operator interfaces. |
static class |
SQLStatementBuilder.DefaultSQLConditionValuesProcessor
This class provides default implementations for the
SQLConditionValuesProcessor interface. |
static interface |
SQLStatementBuilder.Expression
This interface defines the basic methods that must be implemented by any
class that defines a expression to be processed in
SQLConditionValuesProcessor
|
static class |
SQLStatementBuilder.ExtendedSQLConditionValuesProcessor
This class provides a implementation of the
SQLConditionValuesProcessor interface. |
static interface |
SQLStatementBuilder.Field
This interface defines the basic methods that must be implemented by any
class that stores the name of the column that is used by the
Expression when it's processed by
SQLConditionValuesProcessor. |
static class |
SQLStatementBuilder.NoWildCard
This class is used for avoid using wildcard when the condition string is
created in
SQLConditionValuesProcessor |
static interface |
SQLStatementBuilder.Operator
This interface defines the basic methods that must be implemented by
every class that defines the operation that is used by the
Expression when it's processed by
SQLConditionValuesProcessor. |
static class |
SQLStatementBuilder.OperatorUtilities |
static interface |
SQLStatementBuilder.SQLConditionValuesProcessor
This interface defines the basic method that must be implemented by any
class that creates the condition string for a SQL Statement.
|
static class |
SQLStatementBuilder.SQLExpression
This class is used to store a SQL Statement and the required values to be
processed in
SQLConditionValuesProcessor. |
static interface |
SQLStatementBuilder.SQLNameEval |
static class |
SQLStatementBuilder.SQLOrder |
static class |
SQLStatementBuilder.SQLStatement
This class is used to store the information to create a SQL statement and
the required values.
|
| Constructor and Description |
|---|
SQLStatementBuilder() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addSpecialCharacters(char[] c)
Adds characters to the list of special characters.
|
static SQLStatementBuilder.SQLStatement |
createCountQuery(String table,
Hashtable conditions,
Vector wildcards,
Vector countColumns)
Returns a
SQLStatement class that stores the information
needed to execute a query that obtains the number of query records |
static SQLStatementBuilder.SQLStatement |
createDeleteQuery(String table,
Hashtable keysValues)
Returns a
SQLStatement class that stores the information
needed to execute a delete query. |
static SQLStatementBuilder.SQLStatement |
createInsertQuery(String table,
Hashtable attributes)
Returns a
SQLStatement class that stores the information
needed to execute a insert query. |
static SQLStatementBuilder.SQLStatement |
createJoinSelectQuery(String principalTable,
String secondaryTable,
Vector principalKeys,
Vector secondaryKeys,
Vector principalTableRequestedColumns,
Vector secondaryTableRequestedColumns,
Hashtable principalTableConditions,
Hashtable secondaryTableConditions,
Vector wildcards,
Vector columnSorting,
boolean forceDistinct)
Returns a
SQLStatement class that stores the information
needed to execute a select query against two table used a join. |
static SQLStatementBuilder.SQLStatement |
createJoinSelectQuery(String mainTable,
String secondaryTable,
Vector mainKeys,
Vector secondaryKeys,
Vector mainTableRequestedColumns,
Vector secondaryTableRequestedColumns,
Hashtable mainTableConditions,
Hashtable secondaryTableConditions,
Vector wildcards,
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. |
static StringBuffer |
createQueryConditionsSearchValue(Object oValue,
Vector values,
boolean bracket,
Object oKey) |
static String |
createQueryConditionsWithoutWhere(Hashtable conditions,
Vector wildcard,
Vector values) |
static SQLStatementBuilder.SQLStatement |
createSelectQuery(String table,
Vector requestedColumns,
Hashtable conditions,
Vector wildcards)
Returns a
SQLStatement class that stores the information
needed to execute a select query. |
static SQLStatementBuilder.SQLStatement |
createSelectQuery(String table,
Vector requestedColumns,
Hashtable conditions,
Vector wildcards,
Vector columnSorting)
Returns a
SQLStatement class that stores the information
needed to execute a select query. |
static SQLStatementBuilder.SQLStatement |
createSelectQuery(String table,
Vector requestedColumns,
Hashtable conditions,
Vector wildcards,
Vector columnSorting,
boolean descending)
Returns a
SQLStatement class that stores the information
needed to execute a select query. |
static SQLStatementBuilder.SQLStatement |
createSelectQuery(String table,
Vector requestedColumns,
Hashtable conditions,
Vector wildcards,
Vector columnSorting,
boolean descending,
boolean forceDistinct)
Returns a
SQLStatement class that stores the information
needed to execute a select query. |
static SQLStatementBuilder.SQLStatement |
createSelectQuery(String table,
Vector requestedColumns,
Hashtable conditions,
Vector wildcards,
Vector columnSorting,
int recordCount)
Returns a
SQLStatement class that stores the information
needed to execute a select query. |
static SQLStatementBuilder.SQLStatement |
createSelectQuery(String table,
Vector requestedColumns,
Hashtable conditions,
Vector wildcards,
Vector columnSorting,
int recordCount,
boolean descending)
Returns a
SQLStatement class that stores the information
needed to execute a select query. |
static SQLStatementBuilder.SQLStatement |
createSelectQuery(String table,
Vector requestedColumns,
Hashtable conditions,
Vector wildcards,
Vector columnSorting,
int recordCount,
boolean descending,
boolean forceDistinct)
Returns a
SQLStatement class that stores the information
needed to execute a select query. |
static SQLStatementBuilder.SQLStatement |
createUpdateQuery(String table,
Hashtable attributesValues,
Hashtable keysValues)
Returns a
SQLStatement class that stores the information
needed to execute a update query. |
static SQLStatementBuilder.SQLConditionValuesProcessor |
getQueryConditionsProcessor()
Returns a instance of
SQLConditionValuesProcessor that be
used in this class to create the condition string |
static SQLStatementBuilder.SQLNameEval |
getSQLNameEval() |
static SQLStatementHandler |
getSQLStatementHandler(String handlerID) |
static boolean |
isUseAsInSubqueries() |
static String |
qualify(String col,
String table)
Returns a
String with the qualified name. |
static void |
registerSQLStatementHandler(String handlerID,
SQLStatementHandler handler) |
static void |
setSQLConditionValuesProcessor(SQLStatementBuilder.SQLConditionValuesProcessor processor)
Sets the
SQLConditionValuesProcessor |
static void |
setSQLNameEval(SQLStatementBuilder.SQLNameEval eval) |
static void |
setUseAsInSubqueries(boolean useAsInSubqueries) |
public static final String DEFAULT_HANDLER
public static final String POSTGRES_HANDLER
public static final String SQLSERVER_HANDLER
public static final String ORACLE_HANDLER
public static final String HSQLDB_HANDLER
public static final String ACCESS_HANDLER
public static final String MYSQL_HANDLER
protected static final Hashtable registerHandlers
@Deprecated public static boolean useAsInSubqueries
public static boolean DEBUG
public static final String SELECT
public static final String DISTINCT
public static final String WHERE
public static final String ON
public static final String FROM
public static final String LIKE
public static final String NOT_LIKE
public static final String AND
public static final String OR
public static final String LEFT_JOIN
public static final String INNER_JOIN
public static final String IN
public static final String NOT_IN
public static final String COMMA
public static final String QUESTIONMARK
public static final String OPEN_PARENTHESIS
public static final String CLOSE_PARENTHESIS
public static boolean checkParenthesis
public static final String ASTERISK
public static final String OPEN_SQUARE_BRACKET
public static final String CLOSE_SQUARE_BRACKET
public static final String EQUAL_XQUESTIONMARK
public static final String NOT_EQUAL_XQUESTIONMARK
public static final String EQUAL
public static final String NOT_EQUAL
public static final String NOT_EQUAL_ID
public static final String IS_NULL
public static final String NULL
public static final String MORE_EQUAL
public static final String LESS_EQUAL
public static final String MORE_EQUAL_XQUESTIONMARK
public static final String LESS_EQUAL_XQUESTIONMARK
public static final String LESS_XQUESTIONMARK
public static final String MORE_XQUESTIONMARK
public static final String AS
public static final String COUNT_COLUMN
public static final String COUNT_COLUMN_NAME
public static final String COUNT
public static final String TOP
public static final String ORDER_BY
public static final String DESC
public static final String INSERT_INTO
public static final String VALUES
public static final String DELETE_FROM
public static final String UPDATE
public static final String SET
public static final String SPACE
public static final String PIPES
public static char ASTERISK_CHAR
public static char INTERROG
public static char PERCENT
public static char LOW_LINE
public static final String GENERATED_KEY_COLUMN_NAME
public static SQLStatementHandler getSQLStatementHandler(String handlerID)
public static void registerSQLStatementHandler(String handlerID, SQLStatementHandler handler)
public static boolean isUseAsInSubqueries()
public static void setUseAsInSubqueries(boolean useAsInSubqueries)
public static StringBuffer createQueryConditionsSearchValue(Object oValue, Vector values, boolean bracket, Object oKey)
public static void setSQLConditionValuesProcessor(SQLStatementBuilder.SQLConditionValuesProcessor processor)
SQLConditionValuesProcessor to be used in SQLStatementBuilderprocessor - the SQLConditionValuesProcessor instance that be usedpublic static SQLStatementBuilder.SQLStatement createCountQuery(String table, Hashtable conditions, Vector wildcards, Vector countColumns)
SQLStatement class that stores the information
needed to execute a query that obtains the number of query recordstable - name of the table the query is executed againstconditions - condition list used in the querywildcards - column list that can use wildcardsSQLStatement classpublic static SQLStatementBuilder.SQLStatement createSelectQuery(String table, Vector requestedColumns, Hashtable conditions, Vector wildcards)
SQLStatement class that stores the information
needed to execute a select query.table - name of the table the query is executed againstrequestedColumns - a Vector specifying the requested column name in the queryconditions - condition list used to created the querywildcards - SQLStatement classSQLStatementBuilder.SQLStatementpublic static SQLStatementBuilder.SQLStatement createSelectQuery(String table, Vector requestedColumns, Hashtable conditions, Vector wildcards, Vector columnSorting, int recordCount)
SQLStatement class that stores the information
needed to execute a select query.table - name of the table the query is executed againstrequestedColumns - a Vector specifying the requested column name in the queryconditions - condition list used to created the querywildcards - column list that can use wildcardscolumnSorting - column list where query sorting is establishedrecordCount - number of records requested in the querySQLStatement classSQLStatementBuilder.SQLStatementpublic static SQLStatementBuilder.SQLStatement createSelectQuery(String table, Vector requestedColumns, Hashtable conditions, Vector wildcards, Vector columnSorting, int recordCount, boolean descending)
SQLStatement class that stores the information
needed to execute a select query.table - name of the table the query is executed againstrequestedColumns - a Vector specifying the requested column name in the queryconditions - condition list used to created the querywildcards - column list that can use wildcardscolumnSorting - column list where query sorting is establishedrecordCount - number of records requested in the querydescending - true if sorting should be descendingSQLStatement classSQLStatementBuilder.SQLStatementpublic static SQLStatementBuilder.SQLStatement createSelectQuery(String table, Vector requestedColumns, Hashtable conditions, Vector wildcards, Vector columnSorting, int recordCount, boolean descending, boolean forceDistinct)
SQLStatement class that stores the information
needed to execute a select query.table - name of the table the query is executed againstrequestedColumns - a Vector specifying the requested column name in the queryconditions - condition list used to created the querywildcards - column list that can use wildcardscolumnSorting - column list where query sorting is establishedrecordCount - number of records requested in the queryforceDistinct - true if query result cannot have duplicated recordsdescending - true if sorting should be descendingSQLStatement classSQLStatementBuilder.SQLStatementpublic static SQLStatementBuilder.SQLStatement createSelectQuery(String table, Vector requestedColumns, Hashtable conditions, Vector wildcards, Vector columnSorting)
SQLStatement class that stores the information
needed to execute a select query.table - name of the table the query is executed againstrequestedColumns - a Vector specifying the requested column name in the queryconditions - condition list used to created the querywildcards - column list that can use wildcardscolumnSorting - column list where query sorting is establishedSQLStatement classSQLStatementBuilder.SQLStatementpublic static SQLStatementBuilder.SQLStatement createSelectQuery(String table, Vector requestedColumns, Hashtable conditions, Vector wildcards, Vector columnSorting, boolean descending)
SQLStatement class that stores the information
needed to execute a select query.table - name of the table the query is executed againstrequestedColumns - a Vector specifying the requested column name in the queryconditions - condition list used to created the querywildcards - column list that can use wildcardscolumnSorting - column list where query sorting is establisheddescending - true if sorting should be descendingSQLStatement classSQLStatementBuilder.SQLStatementpublic static SQLStatementBuilder.SQLStatement createSelectQuery(String table, Vector requestedColumns, Hashtable conditions, Vector wildcards, Vector columnSorting, boolean descending, boolean forceDistinct)
SQLStatement class that stores the information
needed to execute a select query.table - name of the table the query is executed againstrequestedColumns - a Vector specifying the requested column name in the queryconditions - condition list used to created the querywildcards - column list that can use wildcardscolumnSorting - column list where query sorting is establishedforceDistinct - true if query result cannot have duplicated recordsdescending - true if sorting should be descendingSQLStatement classSQLStatementBuilder.SQLStatementpublic static void setSQLNameEval(SQLStatementBuilder.SQLNameEval eval)
public static SQLStatementBuilder.SQLNameEval getSQLNameEval()
public static SQLStatementBuilder.SQLStatement createInsertQuery(String table, Hashtable attributes)
SQLStatement class that stores the information
needed to execute a insert query.table - name of the table the query is executed againstattributes - 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.public static SQLStatementBuilder.SQLStatement createUpdateQuery(String table, Hashtable attributesValues, Hashtable keysValues)
SQLStatement class that stores the information
needed to execute a update query.table - name of the table the update is executed againstattributesValues - 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.SQLStatementBuilder.SQLStatementpublic static SQLStatementBuilder.SQLStatement createDeleteQuery(String table, Hashtable keysValues)
SQLStatement class that stores the information
needed to execute a delete query.table - name of the table the query is executed againstkeysValues - 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.public static void addSpecialCharacters(char[] c)
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.
c - a array with the new characterspublic static SQLStatementBuilder.SQLStatement createJoinSelectQuery(String principalTable, String secondaryTable, Vector principalKeys, Vector secondaryKeys, Vector principalTableRequestedColumns, Vector secondaryTableRequestedColumns, Hashtable principalTableConditions, Hashtable secondaryTableConditions, Vector wildcards, Vector columnSorting, boolean forceDistinct)
SQLStatement class that stores the information
needed to execute a select query against two table used a join.principalTable - name of the principal table the query is executed againstsecondaryTable - name of the secondary table the query is executed againstprincipalKeys - a Vector specifying the column names of the principal table
that be used to combine the two tablessecondaryKeys - a Vector specifying the column names of the secondary table
that be used to combine the two tablesprincipalTableRequestedColumns - column list that be requested in the query from principal
tablesecondaryTableRequestedColumns - column list that be requested in the query from secondary
tableprincipalTableConditions - a Hashtable specifying conditions that must comply the set of
records returned from principal tablesecondaryTableConditions - a Hashtable specifying conditions that must comply the set of
records returned from secondary tablewildcards - column list which wildcards can be used incolumnSorting - column list where query sorting is establishedforceDistinct - true if query result cannot have duplicated recordsSQLStatement class which stores the SQL Statement
and the required valuespublic static String qualify(String col, String table)
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]
col - a String with the column nametable - a String with the table namepublic static SQLStatementBuilder.SQLStatement createJoinSelectQuery(String mainTable, String secondaryTable, Vector mainKeys, Vector secondaryKeys, Vector mainTableRequestedColumns, Vector secondaryTableRequestedColumns, Hashtable mainTableConditions, Hashtable secondaryTableConditions, Vector wildcards, Vector columnSorting, boolean forceDistinct, boolean descending)
SQLStatement class that stores the information
needed to execute a select query against two table used a join.mainTable - name of the principal table the query is executed againstsecondaryTable - name of the secondary table the query is executed againstmainKeys - a Vector specifying the column names of the principal table
that be used to combine the two tablessecondaryKeys - a Vector specifying the column names of the secondary table
that be used to combine the two tablesmainTableRequestedColumns - column list that be requested in the query from principal
tablesecondaryTableRequestedColumns - column list that be requested in the query from secondary
tablemainTableConditions - a Hashtable specifying conditions that must comply the set of
records returned from principal tablesecondaryTableConditions - a Hashtable specifying conditions that must comply the set of
records returned from secondary tablewildcards - column list which wildcards can be used incolumnSorting - column list where query sorting is establishedforceDistinct - true if query result cannot have duplicated recordsdescending - true if sorting should be descendingSQLStatement class which stores the SQL Statement
and the required valuespublic static SQLStatementBuilder.SQLConditionValuesProcessor getQueryConditionsProcessor()
SQLConditionValuesProcessor that be
used in this class to create the condition stringSQLConditionValuesProcessor classCopyright © 2016 Imatia Innovation S.L.. All rights reserved.