Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle TopLink API Reference 10g Release 3 (10.1.3) B13698-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.toplink.queryframework
Class ObjectLevelReadQuery

`java.lang.Object
oracle.toplink.queryframework.DatabaseQuery
oracle.toplink.queryframework.ReadQuery
oracle.toplink.queryframework.ObjectLevelReadQuery`

All Implemented Interfaces:
  java.lang.Cloneable, java.io.Serializable

Direct Known Subclasses:
  ReadAllQuery, ReadObjectQuery

public abstract class ObjectLevelReadQuery
extends ReadQuery

Purpose: Abstract class for all read queries using objects.

Description: Contains common behavior for all read queries using objects.

Since:
  TOPLink/Java 1.0
See Also:
  Serialized Form

Field Summary
`static int` | `CheckCacheByExactPrimaryKey`
`static int` | `CheckCacheByPrimaryKey`
`static int` | `CheckCacheOnly`
`static int` | `CheckCacheThenDatabase`
`static int` | `ConformResultsInUnitOfWork`
`static short` | `DEFAULT_LOCK_MODE`
`static int` | `DoNotCheckCache`
`static short` | `DONT_USE_DISTINCT`
`static short` | `LOCK`
`static short` | `LOCK_NOWAIT`
`static short` | `NO_LOCK`
`static short` | `UNCOMPUTED_DISTINCT`
`static short` | `USE_DISTINCT`
`static int` | `UseDescriptorSetting`

Fields inherited from class oracle.toplink.queryframework.DatabaseQuery
`CascadeAggregateDelete, CascadeAllParts, CascadeByMapping, CascadeDependentParts, CascadePrivateParts, NoCascading`

Method Summary
`void` | `acquireLocks()` PUBLIC: Set the query to lock, this will also turn refreshCache on.
`void` | `acquireLocksWithoutWaiting()` PUBLIC: Set the query to lock without waiting (blocking), this will also turn refreshCache on.
`void` | `addJoinedAttribute(Expression attributeExpression)` PUBLIC: Specify the one-to-one mapped attribute to be optimized in this query.
`void` | `addJoinedAttribute(java.lang.String attributeName)` PUBLIC: Specify the one-to-one mapped attribute to be optimized in this query.
`void` | `addPartialAttribute(Expression attributeExpression)` PUBLIC: Specify that only a subset of the class' attributes be selected in this query.
`void` | `addPartialAttribute(java.lang.String attributeName)` PUBLIC: Specify that only a subset of the class' attributes be selected in this query.
`void` | `checkCacheOnly()` PUBLIC: The cache will checked completely, if the object is not found null will be returned or an error if the query is too complex.
`void` | `conformResultsInUnitOfWork()` PUBLIC: The cache will checked completely, if the object is not found the database will be queried, and the database result will be verified with what is in the cache and/or unit of work including new objects.
`void` | `dontAcquireLocks()` PUBLIC: Set the query not to lock.
`void` | `dontCheckCache()` PUBLIC: This can be used to explicitly disable the cache hit.
`void` | `dontRefreshIdentityMapResult()` PUBLIC: When unset means perform read normally and dont do refresh.
`void` | `dontRefreshRemoteIdentityMapResult()` PUBLIC: When unset means perform read normally and dont do refresh.
`void` | `dontUseDistinct()` ADVANCED: If a distinct has been set the DISTINCT clause will be printed.
`java.lang.Object` | `executeDatabaseQuery()` INTERNAL: Execute the query
`AsOfClause` | `getAsOfClause()` ADVANCED: Answers the past time this query is as of.
`int` | `getCacheUsage()` PUBLIC: Return the cache usage.
`short` | `getDistinctState()` ADVANCED: If a distinct has been set the DISTINCT clause will be printed.
`java.lang.Object` | `getExampleObject()` PUBLIC: This method returns the current example object.
`ExpressionBuilder` | `getExpressionBuilder()` REQUIRED: Get the expression builder which should be used for this query.
`FetchGroup` | `getFetchGroup()` Return the fetch group set in the query.
`java.lang.String` | `getFetchGroupName()` Return the fetch group name set in the query.
`InMemoryQueryIndirectionPolicy` | `getInMemoryQueryIndirectionPolicy()` PUBLIC: Returns the InMemoryQueryIndirectionPolicy for this query
`short` | `getLockMode()` PUBLIC: Return the current locking mode.
`QueryByExamplePolicy` | `getQueryByExamplePolicy()` PUBLIC: When using Query By Example, an instance of QueryByExamplePolicy is used to customize the query.
`java.lang.Class` | `getReferenceClass()` PUBLIC: Return the reference class of the query.
`boolean` | `hasAsOfClause()` PUBLIC: Answers if the domain objects are to be read as of a past time.
`boolean` | `isLockQuery()` PUBLIC: Answers if the query lock mode is known to be LOCK or LOCK_NOWAIT.
`boolean` | `isLockQuery(Session session)` ADVANCED: Answers if this query will issue any pessimistic locks.
`boolean` | `isObjectLevelReadQuery()` PUBLIC: Return if this is an object level read query.
`void` | `refreshIdentityMapResult()` PUBLIC: Refresh the attributes of the object(s) resulting from the query.
`void` | `refreshRemoteIdentityMapResult()` PUBLIC: Refresh the attributes of the object(s) resulting from the query.
`void` | `resetDistinct()` ADVANCED: If a distinct has been set the DISTINCT clause will be printed.
`void` | `setAsOfClause(AsOfClause pastTime)` ADVANCED: Sets the query to execute as of the past time.
`void` | `setCacheUsage(int cacheUsage)` PUBLIC: Set the cache usage.
`void` | `setDistinctState(short distinctState)` ADVANCED: If a distinct has been set the DISTINCT clause will be printed.
`void` | `setEJBQLString(java.lang.String ejbqlString)` PUBLIC: To any user of this object.
`void` | `setExampleObject(java.lang.Object newExampleObject)` PUBLIC: Set the example object of the query to be the newExampleObject.
`void` | `setFetchGroup(FetchGroup newFetchGroup)` Set a dynamic (use case) fetch group to the query.
`void` | `setFetchGroupName(java.lang.String groupName)` Set a descriptor-level pre-defined named fetch group to the query.
`void` | `setInMemoryQueryIndirectionPolicy(InMemoryQueryIndirectionPolicy inMemoryQueryIndirectionPolicy)` PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query
`void` | `setLockMode(short lockMode)` PUBLIC: Sets whether this is a pessimistically locking query.
`void` | `setQueryByExamplePolicy(QueryByExamplePolicy queryByExamplePolicy)` PUBLIC: The QueryByExamplePolicy, is a useful to customize the query when Query By Example is used.
`void` | `setReferenceClass(java.lang.Class aClass)` REQUIRED: Set the reference class for the query.
`void` | `setSelectionCriteria(Expression expression)` PUBLIC: To any user of this object.
`void` | `setShouldProcessResultsInUnitOfWork(boolean processResultsInUnitOfWork)` ADVANCED: Used for CMP only.
`void` | `setShouldRefreshIdentityMapResult(boolean shouldRefreshIdentityMapResult)` PUBLIC: Set if the attributes of the object(s) resulting from the query should be refreshed.
`void` | `setShouldRefreshRemoteIdentityMapResult(boolean shouldRefreshIdentityMapResult)` PUBLIC: Set if the attributes of the object(s) resulting from the query should be refreshed.
`void` | `setShouldUseDefaultFetchGroup(boolean shouldUseDefaultFetchGroup)` Set false if the user does not want to use the default fetch group defined in the descriptor level.
`void` | `setShouldUseExclusiveConnection(boolean shouldUseExclusiveConnection)` ADVANCED: If the user has isolated data and specified that the client session should use an exclusive connection then by setting this condition to true TopLink will ensure that the query is executed through the exclusive connection.
`boolean` | `shouldCheckCacheOnly()` PUBLIC: Return if cache should be checked.
`boolean` | `shouldCheckDescriptorForCacheUsage()` PUBLIC: Return whether the descriptor's disableCacheHits setting should be checked prior to querying the cache.
`boolean` | `shouldConformResultsInUnitOfWork()` PUBLIC: Should the results will be checked against the changes within the unit of work and object no longer matching or deleted will be remove, matching new objects will also be added..
`boolean` | `shouldProcessResultsInUnitOfWork()` ADVANCED: Used for CMP only.
`boolean` | `shouldRefreshIdentityMapResult()` PUBLIC: Set to a boolean.
`boolean` | `shouldRefreshRemoteIdentityMapResult()` PUBLIC: Set to a boolean.
`boolean` | `shouldUseDefaultFetchGroup()` Return false if the query does not use the default fetch group defined in the descriptor level.
`boolean` | `shouldUseExclusiveConnection()` ADVANCED: If the user has isolated data and specified that the client session should use an exclusive connection then by setting this condition to true TopLink will ensure that the query is executed through the exclusive connection.
`java.lang.String` | `toString()`
`void` | `useDistinct()` ADVANCED: If a distinct has been set the DISTINCT clause will be printed.

Methods inherited from class oracle.toplink.queryframework.ReadQuery
`cacheQueryResults, clearQueryResults, clearQueryResults, doNotCacheQueryResults, getFetchSize, getFirstResult, getMaxRows, getQueryResultsCachePolicy, isReadQuery, setFetchSize, setFirstResult, setMaxRows, setQueryResultsCachePolicy, setShouldCacheQueryResults, shouldCacheQueryResults`

Methods inherited from class oracle.toplink.queryframework.DatabaseQuery
`addArgument, addArgument, addArgument, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, cacheStatement, cascadeAllParts, cascadeByMapping, cascadePrivateParts, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, getCall, getCalls, getDatasourceCall, getDatasourceCalls, getEJBQLString, getHintString, getName, getQueryTimeout, getRedirector, getSelectionCriteria, getSessionName, getSQLStatement, getSQLString, getSQLStrings, getTranslatedSQLString, getTranslatedSQLStrings, hasSessionName, ignoreBindAllParameters, ignoreCacheStatement, isCallQuery, isDataModifyQuery, isDataReadQuery, isDeleteObjectQuery, isExpressionQuery, isInsertObjectQuery, isModifyQuery, isObjectLevelModifyQuery, isReadAllQuery, isReadObjectQuery, isReportQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isWriteObjectQuery, maintainCache, prepareCall, setCall, setDatasourceCall, setHintString, setName, setQueryTimeout, setRedirector, setSessionName, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldUseWrapperPolicy, setSQLStatement, setSQLString, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeByMapping, shouldCascadeParts, shouldCascadePrivateParts, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldUseWrapperPolicy`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### UseDescriptorSetting

    public static final int UseDescriptorSetting

  See Also:
    Constant Field Values

### DoNotCheckCache

    public static final int DoNotCheckCache

  See Also:
    Constant Field Values

### CheckCacheByExactPrimaryKey

    public static final int CheckCacheByExactPrimaryKey

  See Also:
    Constant Field Values

### CheckCacheByPrimaryKey

    public static final int CheckCacheByPrimaryKey

  See Also:
    Constant Field Values

### CheckCacheThenDatabase

    public static final int CheckCacheThenDatabase

  See Also:
    Constant Field Values

### CheckCacheOnly

    public static final int CheckCacheOnly

  See Also:
    Constant Field Values

### ConformResultsInUnitOfWork

    public static final int ConformResultsInUnitOfWork

  See Also:
    Constant Field Values

### NO_LOCK

    public static final short NO_LOCK

  See Also:
    Constant Field Values

### LOCK

    public static final short LOCK

  See Also:
    Constant Field Values

### LOCK_NOWAIT

    public static final short LOCK_NOWAIT

  See Also:
    Constant Field Values

### DEFAULT_LOCK_MODE

    public static final short DEFAULT_LOCK_MODE

  See Also:
    Constant Field Values

### UNCOMPUTED_DISTINCT

    public static final short UNCOMPUTED_DISTINCT

  See Also:
    Constant Field Values

### USE_DISTINCT

    public static final short USE_DISTINCT

  See Also:
    Constant Field Values

### DONT_USE_DISTINCT

    public static final short DONT_USE_DISTINCT

  See Also:
    Constant Field Values

Method Detail

### acquireLocks

    public void acquireLocks()

  PUBLIC: Set the query to lock, this will also turn refreshCache on.

### acquireLocksWithoutWaiting

    public void acquireLocksWithoutWaiting()

  PUBLIC: Set the query to lock without waiting (blocking), this will also turn refreshCache on.

### addJoinedAttribute

    public void addJoinedAttribute(java.lang.String attributeName)

  PUBLIC: Specify the one-to-one mapped attribute to be optimized in this query. The query will join the object(s) being read with the one-to-one attribute, this allows all of the data required for the object(s) to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read. This can be used only for one-to-one mappings where the target is not the same class as the source, either directly or through inheritance. Also two joins cannot be done to the same class.

  Note: This cannot be used for objects where it is possible not to have a part, as these objects will be ommited from the result set, unless an outer join is used through passing and expression using "getAllowingNull".

  Example: query.addJoinedAttribute("address")

  See Also:
    `addJoinedAttribute(Expression)`, `ReadAllQuery.addBatchReadAttribute(Expression)`

### addJoinedAttribute

    public void addJoinedAttribute(Expression attributeExpression)

  PUBLIC: Specify the one-to-one mapped attribute to be optimized in this query. The query will join the object(s) being read with the one-to-one attribute, this allows all of the data required for the object(s) to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read. This can be used only for one-to-one mappings where the target is not the same class as the source, either directly or through inheritance. Also two joins cannot be done to the same class.

  Note: This cannot be used for objects where it is possible not to have a part, as these objects will be ommited from the result set, unless an outer join is used through passing and expression using "getAllowingNull".

  Example: query.addJoinedAttribute(query.getExpressionBuilder().get("teamLeader").get("address"))

  See Also:
    `ReadAllQuery.addBatchReadAttribute(String)`

### addPartialAttribute

    public void addPartialAttribute(java.lang.String attributeName)

  PUBLIC: Specify that only a subset of the class' attributes be selected in this query.

  This allows for the query to be optimized through selecting less data.

  Partial objects will be returned from the query, where the unspecified attributes will be left `null`. The primary key will always be selected to allow re-querying of the whole object.

  Note: Because the object is not fully initialized it cannot be cached, and cannot be edited.

  Note: You cannot have 2 partial attributes of the same type. You also cannot add a partial attribute which is of the same type as the class being queried.

  Example: query.addPartialAttribute("firstName")

  See Also:
    `addPartialAttribute(Expression)`

### setAsOfClause

    public void setAsOfClause(AsOfClause pastTime)

  ADVANCED: Sets the query to execute as of the past time. Both the query execution and result will conform to the database as it existed in the past.

  Equivalent to query.getSelectionCriteria().asOf(pastTime) called immediately before query execution.

  An as of clause at the query level will override any clauses set at the expression level. Useful in cases where the selection criteria is not known in advance, such as for query by example or primary key (selection object), or where you do not need to cache the result (report query).

  Ideally an as of clause at the session level is superior as query results can then be cached. You must set `setShouldMaintainCache(false)`

  To query all joined/batched attributes as of the same time set this.`cascadeAllParts()`.

  Throws:
    `QueryException` - (at execution time) unless `setShouldMaintainCache(false)` is set. If some more recent data were in the cache, this would be returned instead, and both the cache and query result would become inconsistent.
  Since:
    OracleAS TopLink 10g (10.0.3)
  See Also:
    `hasAsOfClause()`, `Session.acquireHistoricalSession(oracle.toplink.history.AsOfClause)`, `Expression.asOf(oracle.toplink.history.AsOfClause)`

### addPartialAttribute

    public void addPartialAttribute(Expression attributeExpression)

  PUBLIC: Specify that only a subset of the class' attributes be selected in this query.

  This allows for the query to be optimized through selecting less data.

  Partial objects will be returned from the query, where the unspecified attributes will be left `null`. The primary key will always be selected to allow re-querying of the whole object.

  Note: Because the object is not fully initialized it cannot be cached, and cannot be edited.

  Note: You cannot have 2 partial attributes of the same type. You also cannot add a partial attribute which is of the same type as the class being queried.

  Example: query.addPartialAttribute(query.getExpressionBuilder().get("address").get("city"))

### checkCacheOnly

    public void checkCacheOnly()

  PUBLIC: The cache will checked completely, if the object is not found null will be returned or an error if the query is too complex. Queries can be configured to use the cache at several levels. Other caching option are available.
  See Also:
    `setCacheUsage(int)`

### conformResultsInUnitOfWork

    public void conformResultsInUnitOfWork()

  PUBLIC: The cache will checked completely, if the object is not found the database will be queried, and the database result will be verified with what is in the cache and/or unit of work including new objects. This can lead to poor performance so it is recomended that only the database be queried in most cases. Queries can be configured to use the cache at several levels. Other caching option are available.
  See Also:
    `setCacheUsage(int)`

### dontAcquireLocks

    public void dontAcquireLocks()

  PUBLIC: Set the query not to lock.

### dontCheckCache

    public void dontCheckCache()

  PUBLIC: This can be used to explicitly disable the cache hit. The cache hit may not be desired in some cases, such as stored procedures that accept the primary key but do not query on it.

### dontRefreshIdentityMapResult

    public void dontRefreshIdentityMapResult()

  PUBLIC: When unset means perform read normally and dont do refresh.

### dontRefreshRemoteIdentityMapResult

    public void dontRefreshRemoteIdentityMapResult()

  PUBLIC: When unset means perform read normally and dont do refresh.

### dontUseDistinct

    public void dontUseDistinct()

  ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by TopLink for batch reading but may also be used directly for advanced queries or report queries.

### executeDatabaseQuery

    public java.lang.Object executeDatabaseQuery()
                                          throws DatabaseException

  Description copied from class: `DatabaseQuery`
  INTERNAL: Execute the query
  Specified by:
    `executeDatabaseQuery` in class `DatabaseQuery`
  Returns:
    - the result of executing the query.
  Throws:
    `DatabaseException` - - an error has occurred on the database.

### getAsOfClause

    public AsOfClause getAsOfClause()

  ADVANCED: Answers the past time this query is as of.
  Returns:
    An immutable object representation of the past time. `null` if no clause set, `AsOfClause.NO_CLAUSE` if clause explicitly set to `null`.
  See Also:
    `AsOfClause`, `setAsOfClause(oracle.toplink.history.AsOfClause)`, `hasAsOfClause()`

### getCacheUsage

    public int getCacheUsage()

  PUBLIC: Return the cache usage. By default only primary key read object queries will first check the cache before accessing the database. Any query can be configure to query against the cache completely, by key or ignore the cache check.

  Valid values are:

  - DoNotCheckCache
  - CheckCacheByExactPrimaryKey
  - CheckCacheByPrimaryKey
  - CheckCacheThenDatabase
  - CheckCacheOnly
  - ConformResultsInUnitOfWork
  - UseDescriptorSetting Note: UseDescriptorSetting functions like CheckCacheByPrimaryKey, except checks the appropriate descriptor's shouldDisableCacheHits setting when querying on the cache. </lu>

    ### getDistinctState

        public short getDistinctState()

      ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by TopLink for batch reading but may also be used directly for advanced queries or report queries.

    ### getExampleObject

        public java.lang.Object getExampleObject()

      PUBLIC: This method returns the current example object. The "example" object is an actual domain object, provided by the client, from which an expression is generated. This expression is used for a query of all objects from the same class, that match the attribute values of the "example" object.

    ### getExpressionBuilder

        public ExpressionBuilder getExpressionBuilder()

      REQUIRED: Get the expression builder which should be used for this query. This expression builder should be used to build all expressions used by this query.

    ### getInMemoryQueryIndirectionPolicy

        public InMemoryQueryIndirectionPolicy getInMemoryQueryIndirectionPolicy()

      PUBLIC: Returns the InMemoryQueryIndirectionPolicy for this query

    ### getLockMode

        public short getLockMode()

      PUBLIC: Return the current locking mode.

    ### getQueryByExamplePolicy

        public QueryByExamplePolicy getQueryByExamplePolicy()

      PUBLIC: When using Query By Example, an instance of QueryByExamplePolicy is used to customize the query. The policy is useful when special operations are to be used for comparisons (notEqual, lessThan, greaterThan, like etc.), when a certain value is to be ignored, or when dealing with nulls.

    ### getReferenceClass

        public java.lang.Class getReferenceClass()

      PUBLIC: Return the reference class of the query.
      Overrides:
        `getReferenceClass` in class `DatabaseQuery`

    ### hasAsOfClause

        public boolean hasAsOfClause()

      PUBLIC: Answers if the domain objects are to be read as of a past time.
      See Also:
        `getAsOfClause()`

    ### isLockQuery

        public boolean isLockQuery()

      PUBLIC: Answers if the query lock mode is known to be LOCK or LOCK_NOWAIT. In the case of DEFAULT_LOCK_MODE and the query reference class being a CMP entity bean, at execution time LOCK, LOCK_NOWAIT, or NO_LOCK will be decided.

      If a single joined attribute was configured for pessimistic locking then this will return true (after first execution) as the SQL contained a FOR UPDATE OF clause.

    ### isLockQuery

        public boolean isLockQuery(Session session)

      ADVANCED: Answers if this query will issue any pessimistic locks.

      If the lock mode is not known (DEFAULT_LOCK_MODE / descriptor specified fine-grained locking) the lock mode will be determined now, to be either LOCK, LOCK_NOWAIT, or NO_LOCK.

      See Also:
        `isLockQuery()`

    ### isObjectLevelReadQuery

        public boolean isObjectLevelReadQuery()

      PUBLIC: Return if this is an object level read query.
      Overrides:
        `isObjectLevelReadQuery` in class `DatabaseQuery`

    ### refreshIdentityMapResult

        public void refreshIdentityMapResult()

      PUBLIC: Refresh the attributes of the object(s) resulting from the query. If cascading is used the private parts of the objects will also be refreshed.

    ### refreshRemoteIdentityMapResult

        public void refreshRemoteIdentityMapResult()

      PUBLIC: Refresh the attributes of the object(s) resulting from the query. If cascading is used the private parts of the objects will also be refreshed.

    ### resetDistinct

        public void resetDistinct()

      ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by TopLink for batch reading but may also be used directly for advanced queries or report queries.

    ### setCacheUsage

        public void setCacheUsage(int cacheUsage)

      PUBLIC: Set the cache usage. By default only primary key read object queries will first check the cache before accessing the database. Any query can be configure to query against the cache completely, by key or ignore the cache check.

      Valid values are:

      - DoNotCheckCache - The query does not check the cache but accesses the database, the cache will still be maintain.
      - CheckCacheByExactPrimaryKey - If the query is exactly and only on the object's primary key the cache will be checked.
      - CheckCacheByPrimaryKey - If the query contains the primary key and possible other values the cache will be checked.
      - CheckCacheThenDatabase - The whole cache will be checked to see if there is any object matching the query, if not the database will be accessed.
      - CheckCacheOnly - The whole cache will be checked to see if there is any object matching the query, if not null or an empty collection is returned.
      - ConformResultsAgainstUnitOfWork - The results will be checked againtst the changes within the unit of work and object no longer matching or deleted will be remove, matching new objects will also be added.
      - shouldCheckDescriptorForCacheUsage - This setting functions like CheckCacheByPrimaryKey, except checks the appropriate descriptor's shouldDisableCacheHits setting when querying on the cache. </lu>

        ### setDistinctState

            public void setDistinctState(short distinctState)

          ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by TopLink for batch reading but may also be used directly for advanced queries or report queries.

        ### setExampleObject

            public void setExampleObject(java.lang.Object newExampleObject)

          PUBLIC: Set the example object of the query to be the newExampleObject. The example object is used for Query By Example. When doing a Query By Example, an instance of the desired object is created, and the fields are filled with the values that are required in the result set. From these values the corresponding expression is built by TopLink, and the query is executed, returning the set of results.

          If a query already has a selection criteria this criteria and the generated query by example criteria will be conjuncted.

          Once a query is executed you must make an explicit call to setExampleObject if the example object is changed, so the query will know to prepare itself again.

          There is a caution to setting both a selection criteria and an example object: Only in this case if you set the example object again after execution you must then also reset the selection criteria. (This is because after execution the original criteria and Query By Example criteria were fused together, and the former cannot be easily recovered from the now invalid result).

        ### setInMemoryQueryIndirectionPolicy

            public void setInMemoryQueryIndirectionPolicy(InMemoryQueryIndirectionPolicy inMemoryQueryIndirectionPolicy)

          PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query

        ### setLockMode

            public void setLockMode(short lockMode)

          PUBLIC: Sets whether this is a pessimistically locking query.
          - ObjectLevelReadQuery.LOCK: SELECT .... FOR UPDATE issued.
          - ObjectLevelReadQuery.LOCK_NOWAIT: SELECT .... FOR UPDATE NO WAIT issued.
          - ObjectLevelReadQuery.NO_LOCK: no pessimistic locking.
          - ObjectLevelReadQuery.DEFAULT_LOCK_MODE (default) and you have a CMP descriptor: fine grained locking will occur.

          Fine Grained Locking: On execution the reference class and those of all joined attributes will be checked. If any of these have a PessimisticLockingPolicy set on their descriptor, they will be locked in a SELECT ... FOR UPDATE OF ... {NO WAIT}. Issues fewer locks and avoids setting the lock mode on each query.

          Example:`readAllQuery.setSelectionCriteria(employee.get("address").equal("Ottawa"));`

          - LOCK: all employees in Ottawa and all referenced Ottawa addresses will be locked.
          - DEFAULT_LOCK_MODE: if address is a joined attribute, and only address has a pessimistic locking policy, only referenced Ottawa addresses will be locked.
          See Also:
            `PessimisticLockingPolicy`

        ### setEJBQLString

            public void setEJBQLString(java.lang.String ejbqlString)

          Description copied from class: `DatabaseQuery`
          PUBLIC: To any user of this object. Set the EJBQL string of the query. If arguments are required in the string they will be preceeded by "?" then the argument number.
          Overrides:
            `setEJBQLString` in class `DatabaseQuery`

        ### setQueryByExamplePolicy

            public void setQueryByExamplePolicy(QueryByExamplePolicy queryByExamplePolicy)

          PUBLIC: The QueryByExamplePolicy, is a useful to customize the query when Query By Example is used. The policy will control what attributes should, or should not be included in the query. When dealing with nulls, using specail operations (notEqual, lessThan, like, etc.) for comparison, or chosing to include certain attributes at all times, it is useful to modify the policy accordingly.

          Once a query is executed you must make an explicit call to setQueryByExamplePolicy when changing the policy, so the query will know to prepare itself again.

          There is a caution to setting both a selection criteria and an example object: If you set the policy after execution you must also reset the selection criteria. (This is because after execution the original criteria and Query By Example criteria are fused together, and the former cannot be easily recovered).

        ### setReferenceClass

            public void setReferenceClass(java.lang.Class aClass)

          REQUIRED: Set the reference class for the query.

        ### setSelectionCriteria

            public void setSelectionCriteria(Expression expression)

          Description copied from class: `DatabaseQuery`
          PUBLIC: To any user of this object. Set the selection criteria of the query. This method be used when dealing with expressions.
          Overrides:
            `setSelectionCriteria` in class `DatabaseQuery`

        ### setShouldRefreshIdentityMapResult

            public void setShouldRefreshIdentityMapResult(boolean shouldRefreshIdentityMapResult)

          PUBLIC: Set if the attributes of the object(s) resulting from the query should be refreshed. If cascading is used the private parts of the objects will also be refreshed.

        ### setShouldRefreshRemoteIdentityMapResult

            public void setShouldRefreshRemoteIdentityMapResult(boolean shouldRefreshIdentityMapResult)

          PUBLIC: Set if the attributes of the object(s) resulting from the query should be refreshed. If cascading is used the private parts of the objects will also be refreshed.

        ### setShouldUseExclusiveConnection

            public void setShouldUseExclusiveConnection(boolean shouldUseExclusiveConnection)

          ADVANCED: If the user has isolated data and specified that the client session should use an exclusive connection then by setting this condition to true TopLink will ensure that the query is executed through the exclusive connection. This may be required in certain cases. An example being where database security will prevent a query joining to a secure table from returning the correct results when executed through the shared connection.

        ### shouldCheckCacheOnly

            public boolean shouldCheckCacheOnly()

          PUBLIC: Return if cache should be checked.

        ### shouldCheckDescriptorForCacheUsage

            public boolean shouldCheckDescriptorForCacheUsage()

          PUBLIC: Return whether the descriptor's disableCacheHits setting should be checked prior to querying the cache.

        ### shouldConformResultsInUnitOfWork

            public boolean shouldConformResultsInUnitOfWork()

          PUBLIC: Should the results will be checked against the changes within the unit of work and object no longer matching or deleted will be remove, matching new objects will also be added..

        ### shouldRefreshIdentityMapResult

            public boolean shouldRefreshIdentityMapResult()

          PUBLIC: Set to a boolean. When set means refresh the instance variables of referenceObject from the database.

        ### shouldRefreshRemoteIdentityMapResult

            public boolean shouldRefreshRemoteIdentityMapResult()

          PUBLIC: Set to a boolean. When set means refresh the instance variables of referenceObject from the database.

        ### toString

            public java.lang.String toString()

          Overrides:
            `toString` in class `DatabaseQuery`

        ### shouldUseExclusiveConnection

            public boolean shouldUseExclusiveConnection()

          ADVANCED: If the user has isolated data and specified that the client session should use an exclusive connection then by setting this condition to true TopLink will ensure that the query is executed through the exclusive connection. This may be required in certain cases. An example being where database security will prevent a query joining to a secure table from returning the correct results when executed through the shared connection.

        ### setShouldProcessResultsInUnitOfWork

            public void setShouldProcessResultsInUnitOfWork(boolean processResultsInUnitOfWork)

          ADVANCED: Used for CMP only. This allows users to indicate whether cmp finders executed at the beginning of a transaction should always be run against a UnitOfWork. Defaults to true.

          If set to false, then UnitOfWork allocation will be deferred until a business method (including creates/removes) or finder with shouldProcessResultsInUnitOfWork == true is invoked. Any finder executed before such a time, will do so against the underlying ServerSession. Forcing finder execution to always go through a UnitOfWork means the results will be cloned and cached in the UnitOfWork up front. This is desired when the results will be accessed in the same transaction.

          Note that finders executed with an unspecified transaction context will never be executed against a UnitOfWork, even if this setting is true. This case may happen with the NotSupported, Never, and Supports attributes.

        ### shouldProcessResultsInUnitOfWork

            public boolean shouldProcessResultsInUnitOfWork()

          ADVANCED: Used for CMP only. Indicates whether cmp finders executed at the beginning of a transaction should always be run against a UnitOfWork. Defaults to true.

          If set to false, then UnitOfWork allocation will be deferred until a business method (including creates/removes) or finder with shouldProcessResultsInUnitOfWork == true is invoked. Any finder executed before such a time, will do so against the underlying ServerSession. Forcing finder execution to always go through a UnitOfWork means the results will be cloned and cached in the UnitOfWork up front. This is desired when the results will be accessed in the same transaction.

          Note that finders executed with an unspecified transaction context will never be executed against a UnitOfWork, even if this setting is true. This case may happen with the NotSupported, Never, and Supports attributes.

        ### useDistinct

            public void useDistinct()

          ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by TopLink for batch reading but may also be used directly for advanced queries or report queries.

        ### getFetchGroup

            public FetchGroup getFetchGroup()

          Return the fetch group set in the query. If a fetch group is not explicitly set in the query, default fetch group optionally defined in the decsiptor would be used, unless the user explicitly calls query.setShouldUseDefaultFetchGroup(false).

        ### setFetchGroup

            public void setFetchGroup(FetchGroup newFetchGroup)

          Set a dynamic (use case) fetch group to the query.

        ### setFetchGroupName

            public void setFetchGroupName(java.lang.String groupName)

          Set a descriptor-level pre-defined named fetch group to the query.

        ### getFetchGroupName

            public java.lang.String getFetchGroupName()

          Return the fetch group name set in the query.

        ### shouldUseDefaultFetchGroup

            public boolean shouldUseDefaultFetchGroup()

          Return false if the query does not use the default fetch group defined in the descriptor level.

        ### setShouldUseDefaultFetchGroup

            public void setShouldUseDefaultFetchGroup(boolean shouldUseDefaultFetchGroup)

          Set false if the user does not want to use the default fetch group defined in the descriptor level.

        Overview | Package | Class | Tree | Deprecated | Index | Help
        | Copyright © 1998, 2006, Oracle. All Rights Reserved.
        PREV CLASS NEXT CLASS | FRAMES NO FRAMES
        SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD