|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.objectweb.cjdbc.common.sql.AbstractRequest
org.objectweb.cjdbc.common.sql.SelectRequest
A SelectRequest is an SQL request of the following syntax:
SELECT [ALL|DISTINCT] select-item[,select-item]* FROM table-specification[,table-specification]* [WHERE search-condition] [GROUP BY grouping-column[,grouping-column]] [HAVING search-condition] [ORDER BY sort-specification[,sort-specification]] [LIMIT ignored]Note that table-specification in the
FROM clause can be a
sub-select. Everything after the end of the WHERE clause is
ignored.
| Field Summary | |
private java.util.ArrayList |
aliasFrom
ArrayList of AliasedTable objects |
static int |
AVERAGE_FUNCTION
Represents a SQL average() macro |
static int |
COUNT_FUNCTION
Represents a SQL count() macro |
private java.lang.String |
cursorName
|
private java.util.ArrayList |
from
ArrayList of String objects. |
int |
funcType
Need to keep track of type of query, e.g. |
static int |
MAX_FUNCTION
Represents a SQL max() macro |
static int |
MIN_FUNCTION
Represents a SQL min() macro |
static int |
NO_FUNCTION
Some values to keep track of function in the SELECT request |
private java.util.ArrayList |
order
ArrayList of OrderBy objects |
private java.lang.String |
pkValue
Primary key value in case of a unique selection |
private java.util.ArrayList |
select
ArrayList of TableColumn objects. |
static int |
SUM_FUNCTION
Represents a SQL sum() macro |
private java.util.ArrayList |
where
ArrayList of TableColumn objects. |
private java.util.Hashtable |
whereValues
Hashtable of String keys corresponding to column names and
String values corresponding to the values associated with the UNIQUE
columns of a UNIQUE SELECT.
|
| Fields inherited from class org.objectweb.cjdbc.common.sql.AbstractRequest |
cacheable, escapeProcessing, id, isAutoCommit, isParsed, isReadOnly, login, maxRows, sqlQuery, sqlSkeleton, timeout, transactionId |
| Constructor Summary | |
SelectRequest(java.lang.String sqlQuery,
boolean escapeProcessing,
int timeout,
java.lang.String lineSeparator)
Creates a new SelectRequest instance. |
|
SelectRequest(java.lang.String sqlQuery,
boolean escapeProcessing,
int timeout,
java.lang.String lineSeparator,
DatabaseSchema schema,
int granularity,
boolean isCaseSensitive)
Creates a new SelectRequest instance. |
|
| Method Summary | |
void |
cloneParsing(AbstractRequest request)
Clones the parsing of a request. |
void |
debug()
Displays some debugging information about this request. |
java.util.ArrayList |
getAliasedFrom()
Returns an ArrayList of AliasedDatabaseTable
objects representing the table names found in the FROM
clause of this request. |
java.lang.String |
getCursorName()
Returns the cursorName value. |
java.util.ArrayList |
getFrom()
Returns an ArrayList of String objects
representing the table names found in the FROM clause of
this request. |
private java.util.ArrayList |
getFromTables(java.lang.String fromClause,
DatabaseSchema schema,
boolean isCaseSensitive)
Extracts the tables from the given FROM clause and retrieves
their alias if any. |
java.util.ArrayList |
getOrderBy()
Returns an ArrayList of OrderBy objects
representing the columns involved in the ORDER BY clause of
this request. |
java.lang.String |
getPkValue()
|
java.util.ArrayList |
getSelect()
Returns an ArrayList of DatabaseColumn
objects representing the columns selected in the SELECT
clause of this request. |
private java.util.ArrayList |
getSelectedColumns(java.lang.String selectClause,
java.util.ArrayList aliasedFrom,
boolean isCaseSensitive)
Gets all the columns selected in the given SELECT clause.
|
java.util.ArrayList |
getWhere()
Returns an ArrayList of TableColumn objects
representing the columns involved in the WHERE clause of
this request. |
private java.util.ArrayList |
getWhereColumns(java.lang.String whereClause,
java.util.ArrayList aliasedFrom,
boolean setUniqueCacheable,
boolean isCaseSensitive)
Gets all the columns involved in the given WHERE clause.
|
java.util.Hashtable |
getWhereValues()
Returns an Hashtable of String keys
representing unique column names and String values
associated with the columns involved in this request. |
boolean |
isReadRequest()
Returns true if this request is a read request (
SELECT requests for example perform a read). |
private boolean |
isSqlFunction(java.lang.String str)
Checks if the string parameter represents an SQL function, e. g., MAX, COUNT, SUM, etc. |
boolean |
isUnknownRequest()
Returns true if the resulting operation on this request is
unknown (some non-standard command or stored procedure for example). |
boolean |
isWriteRequest()
Returns true if this request is a write request (
INSERT or UPDATE for example perform writes). |
void |
parse(DatabaseSchema schema,
int granularity,
boolean isCaseSensitive)
The result of the parsing is accessible through the getSelect(),
getFrom()and getWhere()functions. |
void |
setCursorName(java.lang.String cursorName)
Sets the cursorName value. |
void |
setPkValue(java.lang.String pkValue)
|
| Methods inherited from class org.objectweb.cjdbc.common.sql.AbstractRequest |
equals, getCacheAbility, getEscapeProcessing, getFetchSize, getId, getLineSeparator, getLogin, getMaxRows, getSQL, getSQLShortForm, getSqlSkeleton, getTimeout, getTransactionId, isAutoCommit, isDriverProcessed, isParsed, isReadOnly, setCacheAbility, setDriverProcessed, setFetchSize, setId, setIsAutoCommit, setIsReadOnly, setLineSeparator, setLogin, setMaxRows, setSQL, setSqlSkeleton, setTimeout, setTransactionId, trimCarriageReturn |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private transient java.util.ArrayList select
ArrayList of TableColumn objects.
private transient java.util.ArrayList from
ArrayList of String objects.
private transient java.util.ArrayList aliasFrom
ArrayList of AliasedTable objects
private transient java.util.ArrayList where
ArrayList of TableColumn objects.
private transient java.util.ArrayList order
ArrayList of OrderBy objects
public static final int NO_FUNCTION
public static final int MAX_FUNCTION
public static final int MIN_FUNCTION
public static final int AVERAGE_FUNCTION
public static final int COUNT_FUNCTION
public static final int SUM_FUNCTION
public transient int funcType
private transient java.lang.String pkValue
private transient java.util.Hashtable whereValues
Hashtable of String keys corresponding to column names and
String values corresponding to the values associated with the UNIQUE
columns of a UNIQUE SELECT.
Used with the COLUMN_UNIQUE_DELETE granularity.
CachingGranularitiesprivate java.lang.String cursorName
| Constructor Detail |
public SelectRequest(java.lang.String sqlQuery,
boolean escapeProcessing,
int timeout,
java.lang.String lineSeparator,
DatabaseSchema schema,
int granularity,
boolean isCaseSensitive)
throws java.sql.SQLException
SelectRequest instance. The caller must give
an SQL request, without any leading or trailing spaces and beginning with
'select ' (it will not be checked).
The SQL request is parsed and selected tables and columns are retrieved
using the given DatabaseSchema.
If the syntax is incorrect an exception is thrown.
sqlQuery - the SQL queryescapeProcessing - should the driver to escape processing before
sending to the database ?timeout - an int valuelineSeparator - the line separator used in the queryschema - a DatabaseSchema valuegranularity - parsing granularity as defined in
ParsingGranularitiesisCaseSensitive - true if parsing is case sensitive
java.sql.SQLException - if an error occurs
public SelectRequest(java.lang.String sqlQuery,
boolean escapeProcessing,
int timeout,
java.lang.String lineSeparator)
SelectRequest instance. The caller must give
an SQL request, without any leading or trailing spaces and beginning with
the 'select' keyword (it will not be checked).
The request is not parsed but it can be done later by a call to
parse(DatabaseSchema, int, boolean).
sqlQuery - the SQL queryescapeProcessing - should the driver to escape processing before
sending to the database ?timeout - an int valuelineSeparator - the line separator used in the queryparse(org.objectweb.cjdbc.common.sql.schema.DatabaseSchema, int, boolean)| Method Detail |
public void parse(DatabaseSchema schema,
int granularity,
boolean isCaseSensitive)
throws java.sql.SQLException
The result of the parsing is accessible through the getSelect(),
getFrom()and getWhere()functions.
parse in class AbstractRequestschema - a DatabaseSchema valuegranularity - parsing granularity as defined in
ParsingGranularitiesisCaseSensitive - true if parsing must be case sensitive
java.sql.SQLException - if the parsing failsAbstractRequest.parse(org.objectweb.cjdbc.common.sql.schema.DatabaseSchema,
int, boolean)public void cloneParsing(AbstractRequest request)
AbstractRequest
cloneParsing in class AbstractRequestrequest - the parsed request to cloneAbstractRequest.cloneParsing(AbstractRequest)
private java.util.ArrayList getFromTables(java.lang.String fromClause,
DatabaseSchema schema,
boolean isCaseSensitive)
throws java.sql.SQLException
FROM clause and retrieves
their alias if any.
fromClause - the FROM clause of the request (without
the FROM keyword)schema - the DatabaseSchema this request refers toisCaseSensitive - true if table name parsing is case sensitive
ArrayList of AliasedDatabaseTable
objects
java.sql.SQLException - if an error occurs
private java.util.ArrayList getSelectedColumns(java.lang.String selectClause,
java.util.ArrayList aliasedFrom,
boolean isCaseSensitive)
SELECT clause.
The selected columns or tables must be found in the given
ArrayList of AliasedDatabaseTable
representing the FROM clause of the same request.
selectClause - SELECT clause of the request (without
the SELECT keyword)aliasedFrom - an ArrayList of
AliasedDatabaseTableisCaseSensitive - true if column name parsing is case sensitive
ArrayList of TableColumnprivate boolean isSqlFunction(java.lang.String str)
str - A lower-case string that may represent an SQL function
true if it is an SQL function and
false otherwise.
private java.util.ArrayList getWhereColumns(java.lang.String whereClause,
java.util.ArrayList aliasedFrom,
boolean setUniqueCacheable,
boolean isCaseSensitive)
WHERE clause.
The selected columns or tables must be found in the given
ArrayList of AliasedDatabaseTable
representing the FROM clause of the same request.
whereClause - WHERE clause of the request (without the
WHERE keyword)aliasedFrom - an ArrayList of
AliasedDatabaseTablesetUniqueCacheable - true if we have to check is this select is
UNIQUE or notisCaseSensitive - true if column name parsing is case sensitive
ArrayList of TableColumnpublic java.util.ArrayList getSelect()
ArrayList of DatabaseColumn
objects representing the columns selected in the SELECT
clause of this request.
ArrayList of TableColumnpublic java.util.ArrayList getFrom()
ArrayList of String objects
representing the table names found in the FROM clause of
this request.
ArrayList of Stringpublic java.util.ArrayList getAliasedFrom()
ArrayList of AliasedDatabaseTable
objects representing the table names found in the FROM
clause of this request.
ArrayList of AliasedDatabaseTablepublic java.util.ArrayList getWhere()
ArrayList of TableColumn objects
representing the columns involved in the WHERE clause of
this request.
ArrayList of TableColumnpublic java.util.ArrayList getOrderBy()
ArrayList of OrderBy objects
representing the columns involved in the ORDER BY clause of
this request.
ArrayList of OrderBypublic java.util.Hashtable getWhereValues()
Hashtable of String keys
representing unique column names and String values
associated with the columns involved in this request.
Hashtable valuepublic boolean isReadRequest()
AbstractRequesttrue if this request is a read request (
SELECT requests for example perform a read).
isReadRequest in class AbstractRequesttrueAbstractRequest.isReadRequest()public boolean isWriteRequest()
AbstractRequesttrue if this request is a write request (
INSERT or UPDATE for example perform writes).
isWriteRequest in class AbstractRequestfalseAbstractRequest.isWriteRequest()public boolean isUnknownRequest()
AbstractRequesttrue if the resulting operation on this request is
unknown (some non-standard command or stored procedure for example).
isUnknownRequest in class AbstractRequestfalseAbstractRequest.isUnknownRequest()public java.lang.String getPkValue()
public void setPkValue(java.lang.String pkValue)
pkValue - The pkValue to set.public java.lang.String getCursorName()
public void setCursorName(java.lang.String cursorName)
cursorName - The cursorName to set.public void debug()
debug in class AbstractRequest
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||