Package org.apache.torque.sql

# Klasse Query

java.lang.Object
org.apache.torque.sql.Query

public class Query extends Object
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
  Modifizierer und Typ
  Klasse
  Beschreibung
  `static enum`
  `Query.Type`
  All types of the statement.

- ## Konstruktorübersicht

  Konstruktoren
  Konstruktor
  Beschreibung
  `Query()`

- ## Methodenübersicht

  Modifizierer und Typ
  Methode
  Beschreibung
  `String`
  `getDisplayString()`
  Returns a String to display this query.
  `Integer`
  `getFetchSize()`
  Returns the JDBC statement fetch size to use for queries.
  `String`
  `getForUpdate()`
  Returns the FOR UPDATE clause which should be added to the query.
  `UniqueList<FromElement>`
  `getFromClause()`
  Retrieve the from buffer in order to specify which tables are involved in this query.
  `UniqueList<String>`
  `getGroupByClause()`
  Retrieve the group by columns buffer in order to specify which columns are used to group the results of the query.
  `String`
  `getHaving()`
  Get the having clause.
  `String`
  `getLimit()`
  Get the limit number.
  `String`
  `getOffset()`
  Get the offset number.
  `UniqueList<String>`
  `getOrderByClause()`
  Retrieve the order by columns buffer in order to specify which columns are used to sort the results of the query.
  `String`
  `getPartOperator()`
  Returns the operator connecting the query parts.
  `List<Query>`
  `getParts()`
  Returns the parts of this query.
  `String`
  `getPostLimit()`
  Get the Post limit String.
  `String`
  `getPreLimit()`
  Get the Pre limit String.
  `List<Object>`
  `getPreparedStatementReplacements()`
  Returns all preparedStatementReplacements in the query.
  `String`
  `getRowcount()`
  Get the rowcount number.
  `UniqueList<String>`
  `getSelectClause()`
  Retrieve the columns buffer in order to specify which columns are returned in this query.
  `UniqueList<String>`
  `getSelectModifiers()`
  Retrieve the modifier buffer in order to add modifiers to this query.
  `Query.Type`
  `getType()`
  Returns the type of this SQL statement.
  `ColumnValues`
  `getUpdateValues()`
  Retrieve the values to update to in case of an update statement.
  `UniqueList<String>`
  `getWhereClause()`
  Retrieve the where buffer in order to specify the selection criteria E.g. column_a=?.
  `List<Object>`
  `getWhereClausePreparedStatementReplacements()`
  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`
  `setHaving(String having)`
  Set the having clause.
  `void`
  `setLimit(String limit)`
  Set the limit number.
  `void`
  `setOffset(String offset)`
  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.
  `String`
  `toString()`
  Outputs the query statement.
  `StringBuilder`
  `toStringBuilder(StringBuilder stringBuilder)`
  Appends the query to a string builder.

  ### Von Klasse geerbte Methoden java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Konstruktordetails

  - ### Query

    public Query()

- ## Methodendetails

  - ### getSelectModifiers

    public UniqueList<String> 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

    public UniqueList<String> 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

    public ColumnValues 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

    public UniqueList<FromElement> 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

    public UniqueList<String> 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

    public List<Object> 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

    public List<Object> getPreparedStatementReplacements()
    Returns all preparedStatementReplacements in the query.
    Gibt zurück:
      an unmodifiable list of all preparedStatementReplacements.

  - ### getOrderByClause

    public UniqueList<String> 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

    public UniqueList<String> 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

    public String 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

    public void setHaving(String having)
    Set the having clause. This is used to restrict which rows are returned.
    Parameter:
      `having` - A String.

  - ### getLimit

    public 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

    public void setLimit(String limit)
    Set the limit number. This is used to limit the number of rows returned by a query.
    Parameter:
      `limit` - A String.

  - ### getPreLimit

    public 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

    public void setPreLimit(String preLimit)
    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

    public String 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

    public void setPostLimit(String postLimit)
    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

    public String 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

    public void setOffset(String offset)
    Set the offset number. This is used to set the row where the resultset starts.
    Parameter:
      `offset` - A String.

  - ### getRowcount

    public 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

    public void setRowcount(String rowcount)
    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

    public void setForUpdate(String forUpdate)
    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

    public String 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

    public Query.Type getType()
    Returns the type of this SQL statement.
    Gibt zurück:
      type the new type, not null.

  - ### setType

    public void setType(Query.Type type)
    Sets the type of this SQL statement.
    Parameter:
      `type` - the new type, not null.
    Löst aus:
      `NullPointerException` - if `type` is null.

  - ### getFetchSize

    public Integer getFetchSize()
    Returns the JDBC statement fetch size to use for queries.
    Gibt zurück:
      the fetch size, or null if none is set.

  - ### setFetchSize

    public void setFetchSize(Integer fetchSize)
    Sets the JDBC statement fetch size to use for queries.
    Parameter:
      `fetchSize` - the fetch size, or null for not set.

  - ### getParts

    public List<Query> getParts()
    Returns the parts of this query.
    Gibt zurück:
      a modifiable list containing the parts of this query, not null.

  - ### getPartOperator

    public String getPartOperator()
    Returns the operator connecting the query parts.
    Gibt zurück:
      the operator connecting the parts, or null.

  - ### setPartOperator

    public void setPartOperator(String partOperator)
    Sets the operator connecting the query parts.
    Parameter:
      `partOperator` - the operator connecting the parts, or null.

  - ### toString

    public String toString()
    Outputs the query statement.
    Setzt außer Kraft:
      `toString` in Klasse `Object`
    Gibt zurück:
      A String with the query statement.

  - ### toStringBuilder

    public StringBuilder toStringBuilder(StringBuilder stringBuilder)
    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

    public String getDisplayString() throws TorqueException
    Returns a String to display this query.
    Gibt zurück:
      the SQL query for display.
    Löst aus:
      `TorqueException` - Trouble creating the query string.