Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.stc.eindex.ejb.query
Class QueryObject

    java.lang.Object
      com.stc.eindex.ejb.query.QueryObject

All Implemented Interfaces:
  java.io.Serializable

public class QueryObject
extends java.lang.Object
implements java.io.Serializable

The QueryObject class represents the criteria and conditions of an object query in the master index. It is the primary class for interacting with the Query Manager (class QueryManager), which executes each query. QueryObject holds the query information read by the Query Manager, and is used to set select fields for an object and to set conditions on object fields. The Query Manager transforms the query object into a relational database SQL query. The generated SQL statements contain select fields and conditions as the WHERE clause of the SQL query and always include primary keys of the objects. The statements might also include an "ORDER BY primary_key" clause.

You can query from multiple objects and set conditions on any object attributes. The relationship between objects does not need to be specified by the client; they are obtained internally and mapped by the Query Manager. Use the qualified field name syntax to specify fields (see the eView Studio or eIndex Single Patient Identifier User's Guide for more information about field syntax conventions).

See Also:
  Serialized Form

Constructor Summary
`QueryObject()` Creates a new instance of the QueryObject class.
`QueryObject(QueryObject qo)` This a copy constructor for the QueryObject class and creates a copy of the specified query object.

Method Summary
`void` | `addCondition(Condition condition)` Adds a condition, specified by an instance of the Condition class to the query object.
`void` | `addCondition(java.lang.String field, java.lang.String value)` This is an overload method of addCondition, differing in that the default operator is = (equal to) and the value is a string.
`void` | `addCondition(java.lang.String field, java.lang.String operator, java.lang.Object value)` Specifies a condition for the WHERE clause of the SQL query.
`void` | `addCondition(java.lang.String field, java.lang.String operator, java.lang.String value)` This is an overload method of addCondition, differing in that the value parameter is a String.
`void` | `addSelect(java.lang.String field)` Adds a field to the SELECT portion of the SQL statement.
`(package private) int` | `getResultSetType()` Return the ResultSet Type for the query object.
`void` | `setAssembleDescriptor(AssembleDescriptor assDesc)` Sets the assemble descriptor (class AssembleDescriptor) for the QueryObject.
`void` | `setCondition(Condition[] conditions)` Specifies all the conditions of the query.
`void` | `setCondition(Condition[][] conditions)` Specifies multiple sets of conditions so the query object (more specifically the Query Manager) will logically use a UNION operator between each set of conditions in the SQL statement.
`void` | `setFetchSize(int fetchSize)` Specifies the number of objects to return in each batch.
`void` | `setHints(java.lang.String[][] hints)` Adds database hints to the SELECT statements of the SQL query.
`void` | `setMaxObjects(int maxObjects)` Limits the maximum number of objects returned from a query.
`void` | `setQueryOption(int option)` Specifies a query option that indicates to the parser whether to perform a single or multiple query.
`void` | `setSelect(java.lang.String[] fields)` Specifies multiple fields for the SELECT portion of the SQL statement.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### QueryObject

    public QueryObject()

  Creates a new instance of the QueryObject class.

  Parameters:
    None.
  Throws:
    None.

### QueryObject

    public QueryObject(QueryObject qo)

  This a copy constructor for the QueryObject class and creates a copy of the specified query object. Fields that are constructed after parsing are not copied into the new object, so the new QueryObject must be parsed (using QueryObject.parse).

  Parameters:
    `qo` - The query object to copy.
  Throws:
    None.

Method Detail

### addCondition

    public void addCondition(Condition condition)

  Adds a condition, specified by an instance of the Condition class to the query object.

  Parameters:
    `condition` - The condition to be added to the query object.
  Returns:
    `void` - None.
  Throws:
    None.

### addCondition

    public void addCondition(java.lang.String field,
                             java.lang.String value)

  This is an overload method of addCondition, differing in that the default operator is = (equal to) and the value is a string. This method specifies a condition for the WHERE clause of the SQL query, using an AND operator to join any previous conditions. If a field is of the type "varchar2", the query object automatically encloses the value in quotes.

  Parameters:
    `field` - The fully qualified field name for the WHERE clause.
    `value` - The value for the WHERE clause.
  Returns:
    `void` - None.
  Throws:
    None.

### addCondition

    public void addCondition(java.lang.String field,
                             java.lang.String operator,
                             java.lang.Object value)

  Specifies a condition for the WHERE clause of the SQL query. This method joins the condition to any previous conditions using the AND operator. If a field is of the type "varchar2", the query object will automatically enclose the value in quotes.

  Parameters:
    `field` - The fully qualified field name for the WHERE clause.
    `operator` - The SQL operator for the WHERE clause. Available operators are = (equal to) and LIKE.
    `value` - The value for the WHERE clause. The value can be of the type java.sql.
  Returns:
    `void` - None.
  Throws:
    None.

### addCondition

    public void addCondition(java.lang.String field,
                             java.lang.String operator,
                             java.lang.String value)

  This is an overload method of addCondition, differing in that the value parameter is a String. This method specifies a condition for the WHERE clause of the SQL query, using an AND operator to join any previous conditions added. If a field is of the type "varchar2", the query object automatically encloses the value in quotes.

  Parameters:
    `field` - The fully qualified field name for the WHERE clause.
    `operator` - The SQL operator for the WHERE clause. Available operators are = (equal to) and LIKE.
    `value` - The value for the WHERE clause.
  Returns:
    `void` - None.
  Throws:
    None.

### addSelect

    public void addSelect(java.lang.String field)

  Adds a field to the SELECT portion of the SQL statement. This field is returned by SQL to the query object. Call this method for each field in the SELECT statement, using the fully qualified field name.

  Parameters:
    `field` - The name of a field to include in the SELECT portion of t the SQL statement.
  Returns:
    `void` - None.
  Throws:
    None.

### getResultSetType

    int getResultSetType()

  Return the ResultSet Type for the query object.

  Returns:
    `int` - Type of ResultSet
  Throws:
    None.

### setAssembleDescriptor

    public void setAssembleDescriptor(AssembleDescriptor assDesc)

  Sets the assemble descriptor (class AssembleDescriptor) for the QueryObject. The assemble descriptor contains information used by the assembling engine, such as the structure of the enterprise or system object, the iterator type, and the result object assembler to be used by the assembling engine.

  Note: This method is not required if you intend to delay the assembly of the query object. Use the QueryManager.execute() method instead.

  Parameters:
    `assDesc` - The assemble descriptor to use for this query object.
  Returns:
    `void` - None.
  Throws:
    None.

### setCondition

    public void setCondition(Condition[] conditions)

  Specifies all the conditions of the query. All the conditions for this query object can be set by calling this method once.

  Parameters:
    `conditions` - An array of query conditions (including the name operator, and value).
  Returns:
    `void` - None.
  Throws:
    None.

### setCondition

    public void setCondition(Condition[][] conditions)

  Specifies multiple sets of conditions so the query object (more specifically the Query Manager) will logically use a UNION operator between each set of conditions in the SQL statement. The Condition[] array contains an array of conditions, and the Condition array implicitly contains a UNION operator for all Condition[] arrays.

  Parameters:
    `conditions` - An array of query condition arrays.
  Returns:
    `void` - None.
  Throws:
    None.

### setFetchSize

    public void setFetchSize(int fetchSize)

  Specifies the number of objects to return in each batch.

  Parameters:
    `fetchSize` - The maximum number of objects to return in each batch.
  Returns:
    `void` - None.
  Throws:
    None.

### setHints

    public void setHints(java.lang.String[][] hints)

  Adds database hints to the SELECT statements of the SQL query. The text of each hint is passed to the select statement with no modification. The inner array hints are used when multiple SQL queries are generated by the Query Manager. Each inner String[] element is used for a different SQL query. Each outer array hint (String[][]) is used to add a hint to the corresponding SELECT statement in the UNION generated by the Query Manager (due to the condition added by the setCondition method). For example, "hints[x][y]" adds hints to (x+1) SQL query and to (y+1) UNION SELECT statement. For SQL Server, only OPTION hints are supported. In an OPTION clause, you can include multiple hints but you can only use a specific hint once.

  To use this method properly, determine how many queries are generated by running in DEBUG mode first. Then you can set the SQL text appropriately. If the number of hints is less than the number of generated SELECT statements, the remaining SELECT statements are not passed any hints. If the number of hints is greater than the number of SELECT statements, the extra hints are ignored. The Query Manager automatically adds any necessary delimiters, such as "/*+" to the hint.

  Oracle usage example: To pass the hint "FIRST_ROWS_100" to only the first SELECT statement, use the following: String hints[][] = {{"FIRST_ROWS_100"}}

  SQL Server usage example: To pass the hint "FAST 100" to only the first SELECT statement, use the following: String hints[][] = {{"FAST 100"}}

  Parameters:
    `hints` - An array of hints to add to the SELECT statements generated by the Query Manager.
  Returns:
    `void` - None.
  Throws:
    None.

### setMaxObjects

    public void setMaxObjects(int maxObjects)

  Limits the maximum number of objects returned from a query. Only the required rows are retrieved from the database, so the rows are cut off at the database server rather than at the client. Use this method to improve database performance.

  Note: Internally, the Query Manager may convert maxObjects to "rownum < X" in the WHERE clause (where "X" is the maximum number of objects you specify). The Query Manager may retrieve more rows than specified in order to create the maximum number of objects.

  Parameters:
    `maxObjects` - The maximum number of objects to be retrieved.
  Returns:
    `void` - None.
  Throws:
    None.

### setQueryOption

    public void setQueryOption(int option)

  Specifies a query option that indicates to the parser whether to perform a single or multiple query. Possible options are QueryConstants.SINGLE_QUERY or QueryConstants.MULTIPLE_QUERY. SINGLE_QUERY is used for a tuple query. MULTIPLE_QUERY is used for an object construction query. The default is MULTIPLE_QUERY, which is less redundant than the SINGLE_QUERY option.

  Parameters:
    `option` - An identification code that indicates which query option to use. 1 indicates SINGLE_QUERY; 2 indicates MULTIPLE_QUERY.
  Returns:
    `void` - None.
  Throws:
    None.

### setSelect

    public void setSelect(java.lang.String[] fields)

  Specifies multiple fields for the SELECT portion of the SQL statement.

  Parameters:
    `fields` - An array of fields to be selected in the SQL query.
  Returns:
    `void` - None.
  Throws:
    None.

Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2007 by Sun Microsystems, Inc. All Rights Reserved.