|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.cjdbc.sql.AbstractRequest
org.objectweb.cjdbc.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]Everything after the end of the
WHERE
clause is ignored.
Field Summary | |
private java.util.ArrayList |
from
ArrayList of String objects. |
private java.util.ArrayList |
select
ArrayList of TableColumn objects. |
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.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)
Creates a new SelectRequest instance. |
|
SelectRequest(java.lang.String sqlQuery,
boolean escapeProcessing,
int timeout,
DatabaseSchema schema,
int granularity,
boolean isCaseSensitive)
Creates a new SelectRequest instance. |
Method Summary | |
private void |
buildValues(java.util.ArrayList dbColumns,
java.lang.String whereClause,
java.util.ArrayList aliasedFrom)
Gets all the columns involved in the given WHERE clause and
builds the values associated with UNIQUE columns.
|
private boolean |
buildWhereColumns(java.util.ArrayList dbColumns,
java.lang.String whereClause,
java.util.ArrayList aliasedFrom,
boolean isCaseSensitive)
Gets all the columns involved in the given WHERE clause.
|
void |
cloneParsing(AbstractRequest request)
Clones the parsing of a request. |
void |
debug()
Displays some debugging information about this request. |
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 |
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. |
Methods inherited from class org.objectweb.cjdbc.sql.AbstractRequest |
equals, getCacheAbility, getEscapeProcessing, getId, getLogin, getMaxRows, getSQL, getSqlSkeleton, getTimeout, getTransactionId, isAutoCommit, isParsed, isReadOnly, setCacheAbility, setId, setIsAutoCommit, setIsReadOnly, 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 java.util.ArrayList select
ArrayList
of TableColumn
objects.
private java.util.ArrayList from
ArrayList
of String
objects.
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.
Used with the COLUMN_UNIQUE_DELETE
granularity.
CachingGranularities
Constructor Detail |
public SelectRequest(java.lang.String sqlQuery, boolean escapeProcessing, int timeout, 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
valueschema
- a DatabaseSchema
valuegranularity
- parsing granularity as defined in
ParsingGranularities
isCaseSensitive
- true if parsing is case sensitive
java.sql.SQLException
- if an error occurspublic SelectRequest(java.lang.String sqlQuery, boolean escapeProcessing, int timeout)
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
valueparse(org.objectweb.cjdbc.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 AbstractRequest
schema
- a DatabaseSchema
valuegranularity
- parsing granularity as defined in
ParsingGranularities
isCaseSensitive
- true if parsing must be case sensitive
java.sql.SQLException
- if the parsing failsAbstractRequest.parse(org.objectweb.cjdbc.sql.schema.DatabaseSchema, int, boolean)
public void cloneParsing(AbstractRequest request)
AbstractRequest
cloneParsing
in class AbstractRequest
request
- 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 occursprivate 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
AliasedDatabaseTable
isCaseSensitive
- true if column name parsing is case sensitive
ArrayList
of TableColumn
private 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
AliasedDatabaseTable
setUniqueCacheable
- true if we have to check is this select
is UNIQUE
or notisCaseSensitive
- true if column name parsing is case sensitive
ArrayList
of TableColumn
private boolean buildWhereColumns(java.util.ArrayList dbColumns, java.lang.String whereClause, java.util.ArrayList aliasedFrom, 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.
dbColumns
- an ArrayList
of TableColumn
whereClause
- WHERE
clause of the request (without
the WHERE
keyword)aliasedFrom
- an ArrayList
of
AliasedDatabaseTable
isCaseSensitive
- a boolean tha is true if column name parsing is
case sensitive
true
if the request is
UNIQUE_CACHEABLE
and false
otherwise.private void buildValues(java.util.ArrayList dbColumns, java.lang.String whereClause, java.util.ArrayList aliasedFrom) throws java.sql.SQLException
WHERE
clause and
builds the values associated with UNIQUE columns.
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
AliasedDatabaseTable
ArrayList
of TableColumn
java.sql.SQLException
public java.util.ArrayList getSelect()
ArrayList
of DatabaseColumn
objects representing the columns selected in the SELECT
clause of this request.
ArrayList
of TableColumn
public java.util.ArrayList getFrom()
ArrayList
of String
objects
representing the table names found in the FROM
clause of this
request.
ArrayList
of String
public java.util.ArrayList getWhere()
ArrayList
of TableColumn
objects representing the columns involved in the WHERE
clause
of this request.
ArrayList
of TableColumn
public 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()
AbstractRequest
true
if this request is a read request
(SELECT
requests for example perform a read).
isReadRequest
in class AbstractRequest
true
AbstractRequest.isReadRequest()
public boolean isWriteRequest()
AbstractRequest
true
if this request is a write request
(INSERT
or UPDATE
for example perform writes).
isWriteRequest
in class AbstractRequest
false
AbstractRequest.isWriteRequest()
public boolean isUnknownRequest()
AbstractRequest
true
if the resulting operation on this request is
unknown (some non-standard command or stored procedure for example).
isUnknownRequest
in class AbstractRequest
false
AbstractRequest.isUnknownRequest()
public void debug()
debug
in class AbstractRequest
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |