Package org.apache.torque.sql
Klasse Query
java.lang.Object
org.apache.torque.sql.Query
Contains the various parts of a SQL statement (select, update or delete).
Attributes exist for the sections of these statements:
modifiers, columns, from clause, where clause, and order by clause.
Most parts of the query are appended to buffers which only accept
unique entries.
- Version:
- $Id: Query.java 1867515 2019-09-25 15:02:03Z gk $ TODO rename to SqlStatement
- Autor:
- John D. McNally, Sam Joseph, Martin Poeschl, Thomas Fischer
-
Verschachtelte Klassen - Übersicht
Verschachtelte Klassen -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungReturns a String to display this query.Returns the JDBC statement fetch size to use for queries.Returns the FOR UPDATE clause which should be added to the query.Retrieve the from buffer in order to specify which tables are involved in this query.Retrieve the group by columns buffer in order to specify which columns are used to group the results of the query.Get the having clause.getLimit()
Get the limit number.Get the offset number.Retrieve the order by columns buffer in order to specify which columns are used to sort the results of the query.Returns the operator connecting the query parts.getParts()
Returns the parts of this query.Get the Post limit String.Get the Pre limit String.Returns all preparedStatementReplacements in the query.Get the rowcount number.Retrieve the columns buffer in order to specify which columns are returned in this query.Retrieve the modifier buffer in order to add modifiers to this query.getType()
Returns the type of this SQL statement.Retrieve the values to update to in case of an update statement.Retrieve the where buffer in order to specify the selection criteria E.g. column_a=?.Retrieves the replacements which are inserted into prepared statement placeholders in the where clause.boolean
hasLimit()
True if this query has a limit clause registered.void
setFetchSize
(Integer fetchSize) Sets the JDBC statement fetch size to use for queries.void
setForUpdate
(String forUpdate) Sets the FOR UPDATE clause which should be added to the query.void
Set the having clause.void
Set the limit number.void
Set the offset number.void
setPartOperator
(String partOperator) Sets the operator connecting the query parts.void
setPostLimit
(String postLimit) Set the Post limit String.void
setPreLimit
(String preLimit) Get the Pre limit String.void
setRowcount
(String rowcount) Set the rowcount number.void
setType
(Query.Type type) Sets the type of this SQL statement.toString()
Outputs the query statement.toStringBuilder
(StringBuilder stringBuilder) Appends the query to a string builder.
-
Konstruktordetails
-
Query
public Query()
-
-
Methodendetails
-
getSelectModifiers
Retrieve the modifier buffer in order to add modifiers to this query. E.g. DISTINCT and ALL.- Gibt zurück:
- An UniqueList used to add modifiers.
-
getSelectClause
Retrieve the columns buffer in order to specify which columns are returned in this query.- Gibt zurück:
- An UniqueList used to add columns to be selected.
-
getUpdateValues
Retrieve the values to update to in case of an update statement.- Gibt zurück:
- A modifiable ColumnValues object containing the current update values.
-
getFromClause
Retrieve the from buffer in order to specify which tables are involved in this query.- Gibt zurück:
- An UniqueList used to add tables involved in the query.
-
getWhereClause
Retrieve the where buffer in order to specify the selection criteria E.g. column_a=?. Expressions added to the buffer will be separated using AND.- Gibt zurück:
- An UniqueList used to add selection criteria.
-
getWhereClausePreparedStatementReplacements
Retrieves the replacements which are inserted into prepared statement placeholders in the where clause. The number and order of the elements in the list must correspond to the order of the placeholders in the where clause string.- Gibt zurück:
- A List containing all the replacements for the prepared statement placeholders, not null.
-
getPreparedStatementReplacements
Returns all preparedStatementReplacements in the query.- Gibt zurück:
- an unmodifiable list of all preparedStatementReplacements.
-
getOrderByClause
Retrieve the order by columns buffer in order to specify which columns are used to sort the results of the query.- Gibt zurück:
- An UniqueList used to add columns to sort on.
-
getGroupByClause
Retrieve the group by columns buffer in order to specify which columns are used to group the results of the query.- Gibt zurück:
- An UniqueList used to add columns to group on.
-
getHaving
Get the having clause. This is used to restrict which rows are returned based on some condition.- Gibt zurück:
- A String that is the having clause.
-
setHaving
Set the having clause. This is used to restrict which rows are returned.- Parameter:
having
- A String.
-
getLimit
Get the limit number. This is used to limit the number of returned by a query in Postgres.- Gibt zurück:
- A String with the limit.
-
setLimit
Set the limit number. This is used to limit the number of rows returned by a query.- Parameter:
limit
- A String.
-
getPreLimit
Get the Pre limit String. Oracle and DB2 want to encapsulate a query into a subquery for limiting.- Gibt zurück:
- A String with the preLimit.
-
setPreLimit
Get the Pre limit String. Oracle and DB2 want to encapsulate a query into a subquery for limiting.- Parameter:
preLimit
- A String with the preLimit.
-
getPostLimit
Get the Post limit String. Oracle and DB2 want to encapsulate a query into a subquery for limiting.- Gibt zurück:
- A String with the preLimit.
-
setPostLimit
Set the Post limit String. Oracle and DB2 want to encapsulate a query into a subquery for limiting.- Parameter:
postLimit
- A String with the postLimit.
-
getOffset
Get the offset number. This is used to set the row where the resultset starts.- Gibt zurück:
- A String with the offset, or null if no offset is set.
-
setOffset
Set the offset number. This is used to set the row where the resultset starts.- Parameter:
offset
- A String.
-
getRowcount
Get the rowcount number. This is used to limit the number of returned by a query in Sybase and MS SQL/Server.- Gibt zurück:
- A String with the row count.
-
setRowcount
Set the rowcount number. This is used to limit the number of rows returned by Sybase and MS SQL/Server.- Parameter:
rowcount
- A String.
-
setForUpdate
Sets the FOR UPDATE clause which should be added to the query.- Parameter:
forUpdate
- the FOR UPDATE clause which should be added, null if no FOR UPDATE clause should be used.
-
getForUpdate
Returns the FOR UPDATE clause which should be added to the query.- Gibt zurück:
- the FOR UPDATE clause, or null if none should be added.
-
hasLimit
public boolean hasLimit()True if this query has a limit clause registered.- Gibt zurück:
- true if a limit clause exists.
-
getType
Returns the type of this SQL statement.- Gibt zurück:
- type the new type, not null.
-
setType
Sets the type of this SQL statement.- Parameter:
type
- the new type, not null.- Löst aus:
NullPointerException
- iftype
is null.
-
getFetchSize
Returns the JDBC statement fetch size to use for queries.- Gibt zurück:
- the fetch size, or null if none is set.
-
setFetchSize
Sets the JDBC statement fetch size to use for queries.- Parameter:
fetchSize
- the fetch size, or null for not set.
-
getParts
Returns the parts of this query.- Gibt zurück:
- a modifiable list containing the parts of this query, not null.
-
getPartOperator
Returns the operator connecting the query parts.- Gibt zurück:
- the operator connecting the parts, or null.
-
setPartOperator
Sets the operator connecting the query parts.- Parameter:
partOperator
- the operator connecting the parts, or null.
-
toString
Outputs the query statement. -
toStringBuilder
Appends the query to a string builder.- Parameter:
stringBuilder
- the stringBuilder to append to, not null.- Gibt zurück:
- the modified passed in string builder.
-
getDisplayString
Returns a String to display this query.- Gibt zurück:
- the SQL query for display.
- Löst aus:
TorqueException
- Trouble creating the query string.
-