|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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.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. |
private static long |
serialVersionUID
|
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, cursorName, escapeProcessing, fetchSize, id, isAutoCommit, isParsed, isReadOnly, login, maxRows, requestType, sqlQuery, sqlSkeleton, timeoutInSeconds, transactionId, transactionIsolation |
Constructor Summary | |
SelectRequest(CJDBCInputStream in)
|
|
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.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. |
private boolean |
isSqlFunction(java.lang.String str)
Checks if the string parameter represents an SQL function, e. g., MAX, COUNT, SUM, etc. |
boolean |
needsMacroProcessing()
Returns true if this request requires macro (RAND(), NOW(),
...) processing. |
void |
parse(DatabaseSchema schema,
int granularity,
boolean isCaseSensitive)
The result of the parsing is accessible through the getSelect() ,
getFrom() and getWhere() functions. |
boolean |
returnsResultSet()
Does this request returns a ResultSet? |
void |
sendToStream(CJDBCOutputStream out,
boolean needSqlSkeleton)
Serialize the request on the output stream by sending only the needed parameters to reconstruct it on the controller. |
void |
setPkValue(java.lang.String pkValue)
|
Methods inherited from class org.objectweb.cjdbc.common.sql.AbstractRequest |
equals, getCacheAbility, getCursorName, getEscapeProcessing, getFetchSize, getId, getLineSeparator, getLogin, getMaxRows, getSQL, getSQLShortForm, getSqlSkeleton, getTimeout, getTransactionId, getTransactionIsolation, isAlter, isAutoCommit, isCreate, isDDL, isDelete, isDML, isDriverProcessed, isDrop, isInsert, isParsed, isReadOnly, isSelect, isUpdate, receiveResultSetParams, sendResultSetParams, setCacheAbility, setCursorName, setDriverProcessed, setFetchSize, setId, setIsAutoCommit, setIsReadOnly, setLogin, setMaxRows, setSQL, setSqlSkeleton, setTimeout, setTransactionId, setTransactionIsolation, trimCarriageReturnAndTabs |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final long serialVersionUID
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.
CachingGranularities
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
ParsingGranularities
isCaseSensitive
- true if parsing is case sensitive
java.sql.SQLException
- if an error occurspublic 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)
public SelectRequest(CJDBCInputStream in) throws java.io.IOException
AbstractRequest.AbstractRequest(CJDBCInputStream, int)
Method Detail |
public void sendToStream(CJDBCOutputStream out, boolean needSqlSkeleton) throws java.io.IOException
AbstractRequest
sendToStream
in class AbstractRequest
out
- destination CJDBCOutputStreamneedSqlSkeleton
- true if controller wants SQL templates
java.io.IOException
- if failsAbstractRequest
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.common.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
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 getAliasedFrom()
ArrayList
of AliasedDatabaseTable
objects representing the table names found in the FROM
clause of this request.
ArrayList
of AliasedDatabaseTable
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.ArrayList getOrderBy()
ArrayList
of OrderBy
objects
representing the columns involved in the ORDER BY
clause of
this request.
ArrayList
of OrderBy
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 needsMacroProcessing()
AbstractRequest
true
if this request requires macro (RAND(), NOW(),
...) processing.
needsMacroProcessing
in class AbstractRequest
true
AbstractRequest.needsMacroProcessing()
public boolean returnsResultSet()
AbstractRequest
returnsResultSet
in class AbstractRequest
AbstractRequest.returnsResultSet()
public java.lang.String getPkValue()
public void setPkValue(java.lang.String pkValue)
pkValue
- The pkValue 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 |