Oracle Application Server TopLink API Reference
10g Release 2 (10.1.2)

B15903-01


oracle.toplink.queryframework
Class ObjectLevelReadQuery

java.lang.Object
  extended byoracle.toplink.queryframework.DatabaseQuery
      extended byoracle.toplink.queryframework.ReadQuery
          extended byoracle.toplink.queryframework.ObjectLevelReadQuery

All Implemented Interfaces:
java.lang.Cloneable, oracle.toplink.internal.helper.FalseUndefinedTrue, 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 int DoNotCheckCache
static short DONT_USE_DISTINCT
InMemoryQueryIndirectionPolicy inMemoryQueryIndirectionPolicy
Used to determine behaviour of indirection in InMemoryQuerying
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, CascadeDependentParts, CascadePrivateParts, NoCascading, QUERY_PREPARE

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.
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.
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 hasJoinedMappings()
boolean isLockQuery()
PUBLIC: Return true if query is in any lockMode other than NO_LOCK
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 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 setExampleObject(java.lang.Object newExampleObject)
PUBLIC: Set the example object of the query to be the newExampleObject.
void setInMemoryQueryIndirectionPolicy(InMemoryQueryIndirectionPolicy inMemoryQueryIndirectionPolicy)
PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query
void setLockMode(short lockMode)
PUBLIC: Set the lock mode of the query NO_LOCK, LOCK, or LOCK_NOWAIT (default=NO_LOCK)
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 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.
boolean shouldCheckCacheOnly()
PUBLIC: Return if cache should be checked.
boolean shouldCheckDescriptorForCacheUsage()
boolean shouldConformResultsInUnitOfWork()
PUBLIC: Return if cache should be checked.
boolean shouldRefreshIdentityMapResult()
PUBLIC: Set to a boolean.
boolean shouldRefreshRemoteIdentityMapResult()
PUBLIC: Set to a boolean.
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, doNotCacheQueryResults, getMaxRows, isReadQuery, setMaxRows, setShouldCacheQueryResults, shouldCacheQueryResults

Methods inherited from class oracle.toplink.queryframework.DatabaseQuery
addArgument, addArgument, addArgument, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, cacheStatement, cascadeAllParts, cascadePrivateParts, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, getCall, getEJBQLString, getHintString, getName, getQueryTimeout, getRedirector, getSelectionCriteria, getSessionName, getSQLStatement, getSQLString, getTranslatedSQLString, hasSessionName, ignoreBindAllParameters, ignoreCacheStatement, isCallQuery, isDataModifyQuery, isDataReadQuery, isDeleteObjectQuery, isExpressionQuery, isModifyQuery, isObjectLevelModifyQuery, isReadAllQuery, isReadObjectQuery, isReportQuery, isSQLCallQuery, isWriteObjectQuery, maintainCache, prepareCall, setCall, setEJBQLString, setHintString, setName, setQueryTimeout, setRedirector, setSelectionCriteria, setSessionName, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldUseWrapperPolicy, setSQLStatement, setSQLString, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, 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

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

inMemoryQueryIndirectionPolicy

public InMemoryQueryIndirectionPolicy inMemoryQueryIndirectionPolicy
Used to determine behaviour of indirection in InMemoryQuerying

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)

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.

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: