EclipseLink 1.2.0, build 'v20091016-r5565' API Reference

org.eclipse.persistence.queries
Class DataReadQuery

java.lang.Object
  extended by org.eclipse.persistence.queries.DatabaseQuery
      extended by org.eclipse.persistence.queries.ReadQuery
          extended by org.eclipse.persistence.queries.DataReadQuery
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
DirectReadQuery

public class DataReadQuery
extends ReadQuery

Purpose: Concrete class to perform read using raw SQL.

Responsibilities: Execute a selecting raw SQL string. This returns a Collection of the Records representing the result set.

See Also:
Serialized Form
Author:
Yvon Lavoie
Since:
TOPLink/Java 1.0

Field Summary
static int ARRAY
          An Object[] of values is returned for each row.
static int ATTRIBUTE
          A single value is returned for each row.
static int AUTO
          Auto, a single value if a single field is selected, otherwise an Object[] (JPA default).
protected  org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy
           
static int MAP
          A Map (DatabaseRecord) is returned for each row.
protected  int resultType
          Allow return type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, i.e.
static int VALUE
          A single value is returned.
 
Fields inherited from class org.eclipse.persistence.queries.ReadQuery
fetchSize, firstResult, maxRows, queryId, queryResultCachingPolicy, temporaryCachedQueryResults
 
Fields inherited from class org.eclipse.persistence.queries.DatabaseQuery
accessor, argumentFields, arguments, argumentTypeNames, argumentTypes, argumentValues, CascadeAggregateDelete, CascadeAllParts, CascadeByMapping, CascadeDependentParts, cascadePolicy, CascadePrivateParts, descriptor, doNotRedirect, executionSession, flushOnExecute, hintString, isCustomQueryUsed, isExecutionClone, isNativeConnectionRequired, isPrepared, isUserDefined, name, NoCascading, properties, queryMechanism, queryTimeout, redirector, session, sessionName, shouldBindAllParameters, shouldCacheStatement, shouldCloneCall, shouldMaintainCache, shouldPrepare, shouldRetrieveBypassCache, shouldStoreBypassCache, shouldUseWrapperPolicy, sourceMapping, translationRow
 
Constructor Summary
DataReadQuery()
          PUBLIC: Initialize the state of the query.
DataReadQuery(Call call)
          PUBLIC: Initialize the query to use the specified call.
DataReadQuery(java.lang.String sqlString)
          PUBLIC: Initialize the query to use the specified SQL string.
 
Method Summary
 java.lang.Object buildObject(org.eclipse.persistence.internal.sessions.AbstractRecord row)
          INTERNAL: Build the result value for the row.
 void cacheResult(java.lang.Object results)
          INTERNAL: This method is called by the object builder when building an original.
 java.lang.Object clone()
          INTERNAL: Clone the query.
 java.lang.Object execute(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord row)
          INTERNAL: Execute the query.
 java.lang.Object executeDatabaseQuery()
          INTERNAL: Execute the query.
protected  java.lang.Object executeNonCursor()
          INTERNAL: The results are *not* in a cursor, build the collection.
 org.eclipse.persistence.internal.queries.ContainerPolicy getContainerPolicy()
          PUBLIC: Return the query's ContainerPolicy.
 int getResultType()
          Return the result type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, DatabaseRecord).
 Converter getValueConverter()
          INTERNAL: Conversion not supported.
 boolean isDataReadQuery()
          PUBLIC: Return if this is a data read query.
protected  void prepare()
          INTERNAL: Prepare the receiver for execution in a session.
 void prepareForExecution()
          INTERNAL: Prepare the receiver for execution in a session.
 java.lang.Object remoteExecute()
          INTERNAL:
 void setContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy)
          PUBLIC: Set the container policy.
 void setResultType(int resultType)
          Set the result type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, DatabaseRecord).
 void setResultType(java.lang.String resultType)
          Set the result type to be configured, Map, Array, Value, Attribute (Map is the default, DatabaseRecord).
 void useCollectionClass(java.lang.Class concreteClass)
          PUBLIC: Configure the query to use an instance of the specified container class to hold the target objects.
 void useCursoredStream()
          PUBLIC: Use a CursoredStream as the result collection.
 void useCursoredStream(int initialReadSize, int pageSize)
          PUBLIC: Use a CursoredStream as the result collection.
 void useCursoredStream(int initialReadSize, int pageSize, ValueReadQuery sizeQuery)
          PUBLIC: Use a CursoredStream as the result collection.
 void useScrollableCursor()
          PUBLIC: Use a ScrollableCursor as the result collection.
 void useScrollableCursor(int pageSize)
          PUBLIC: Use a ScrollableCursor as the result collection.
 void useScrollableCursor(ScrollableCursorPolicy policy)
          PUBLIC: Use a ScrollableCursor as the result collection.
 
Methods inherited from class org.eclipse.persistence.queries.ReadQuery
cacheQueryResults, clearQueryResults, clonedQueryExecutionComplete, copyFromQuery, doNotCacheQueryResults, getFetchSize, getFirstResult, getMaxRows, getQueryId, getQueryResults, getQueryResults, getQueryResults, getQueryResultsCachePolicy, getTemporaryCachedQueryResults, isDefaultPropertiesQuery, isReadQuery, remoteExecute, setFetchSize, setFirstResult, setMaxRows, setQueryId, setQueryResults, setQueryResultsCachePolicy, setTemporaryCachedQueryResults, shouldCacheQueryResults
 
Methods inherited from class org.eclipse.persistence.queries.DatabaseQuery
addArgument, addArgument, addArgument, addArgumentByTypeName, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, buildArgumentFields, buildSelectionCriteria, cacheStatement, cascadeAllParts, cascadeByMapping, cascadeOnlyDependentParts, cascadePrivateParts, checkDescriptor, checkEarlyReturn, checkForCustomQuery, checkPrepare, checkPrepare, convertClassNamesToClasses, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, executeInUnitOfWork, extractRemoteResult, getAccessor, getArguments, getArgumentTypeNames, getArgumentTypes, getArgumentValues, getCall, getCascadePolicy, getDatasourceCall, getDatasourceCalls, getDefaultRedirector, getDescriptor, getDomainClassNounName, getDoNotRedirect, getEJBQLString, getExecutionSession, getFlushOnExecute, getHintString, getJPQLString, getName, getProperties, getProperty, getQueryMechanism, getQueryNounName, getQueryTimeout, getRedirector, getReferenceClass, getReferenceClassName, getSelectionCriteria, getSensorName, getSession, getSessionName, getShouldBindAllParameters, getSourceMapping, getSQLStatement, getSQLString, getSQLStrings, getTranslatedSQLString, getTranslatedSQLStrings, getTranslationRow, hasAccessor, hasArguments, hasProperties, hasQueryMechanism, hasSessionName, ignoreBindAllParameters, ignoreCacheStatement, isCallQuery, isCascadeOfAggregateDelete, isCustomQueryUsed, isCustomSelectionQuery, isDataModifyQuery, isDeleteAllQuery, isDeleteObjectQuery, isDirectReadQuery, isExecutionClone, isExpressionQuery, isInsertObjectQuery, isJPQLCallQuery, isModifyAllQuery, isModifyQuery, isNativeConnectionRequired, isObjectBuildingQuery, isObjectLevelModifyQuery, isObjectLevelReadQuery, isPrepared, isReadAllQuery, isReadObjectQuery, isReportQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isValueReadQuery, isWriteObjectQuery, maintainCache, prepareCall, prepareCustomQuery, prepareForRemoteExecution, prepareFromQuery, redirectQuery, removeProperty, replaceValueHoldersIn, retrieveBypassCache, rowFromArguments, setAccessor, setArguments, setArgumentTypeNames, setArgumentTypes, setArgumentValues, setCall, setCascadePolicy, setDatasourceCall, setDescriptor, setDoNotRedirect, setEJBQLString, setExecutionSession, setFlushOnExecute, setHintString, setIsCustomQueryUsed, setIsExecutionClone, setIsNativeConnectionRequired, setIsPrepared, setIsUserDefined, setJPQLString, setName, setProperties, setProperty, setQueryMechanism, setQueryTimeout, setRedirector, setSelectionCriteria, setSession, setSessionName, setShouldBindAllParameters, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldRetrieveBypassCache, setShouldStoreBypassCache, setShouldUseWrapperPolicy, setSourceMapping, setSQLStatement, setSQLString, setTranslationRow, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeByMapping, shouldCascadeOnlyDependentParts, shouldCascadeParts, shouldCascadePrivateParts, shouldCloneCall, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldRetrieveBypassCache, shouldStoreBypassCache, shouldUseWrapperPolicy, storeBypassCache, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

containerPolicy

protected org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy

resultType

protected int resultType
Allow return type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, i.e. DatabaseRecord).


MAP

public static final int MAP
A Map (DatabaseRecord) is returned for each row.

See Also:
Constant Field Values

ARRAY

public static final int ARRAY
An Object[] of values is returned for each row.

See Also:
Constant Field Values

VALUE

public static final int VALUE
A single value is returned.

See Also:
Constant Field Values

ATTRIBUTE

public static final int ATTRIBUTE
A single value is returned for each row.

See Also:
Constant Field Values

AUTO

public static final int AUTO
Auto, a single value if a single field is selected, otherwise an Object[] (JPA default).

See Also:
Constant Field Values
Constructor Detail

DataReadQuery

public DataReadQuery()
PUBLIC: Initialize the state of the query.


DataReadQuery

public DataReadQuery(java.lang.String sqlString)
PUBLIC: Initialize the query to use the specified SQL string. Warning: Allowing an unverified SQL string to be passed into this method makes your application vulnerable to SQL injection attacks.


DataReadQuery

public DataReadQuery(Call call)
PUBLIC: Initialize the query to use the specified call.

Method Detail

cacheResult

public void cacheResult(java.lang.Object results)
INTERNAL:

This method is called by the object builder when building an original. It will cause the original to be cached in the query results if the query is set to do so.

Specified by:
cacheResult in class ReadQuery

clone

public java.lang.Object clone()
INTERNAL: Clone the query.

Overrides:
clone in class DatabaseQuery

execute

public java.lang.Object execute(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                org.eclipse.persistence.internal.sessions.AbstractRecord row)
                         throws DatabaseException
INTERNAL: Execute the query. If there are cached results return those. This must override the super to support result caching.

Overrides:
execute in class DatabaseQuery
Parameters:
aSession - - the session in which the receiver will be executed.
Returns:
An object or vector, the result of executing the query.
Throws:
DatabaseException - - an error has occurred on the database

executeDatabaseQuery

public java.lang.Object executeDatabaseQuery()
                                      throws DatabaseException
INTERNAL: Execute the query. Perform the work to execute the SQL string.

Specified by:
executeDatabaseQuery in class DatabaseQuery
Returns:
a collection or cursor of Records representing the result set
Throws:
DatabaseException - an error has occurred on the database

getValueConverter

public Converter getValueConverter()
INTERNAL: Conversion not supported.


buildObject

public java.lang.Object buildObject(org.eclipse.persistence.internal.sessions.AbstractRecord row)
INTERNAL: Build the result value for the row.

Overrides:
buildObject in class ReadQuery

executeNonCursor

protected java.lang.Object executeNonCursor()
                                     throws DatabaseException
INTERNAL: The results are *not* in a cursor, build the collection. Cache the results in temporaryCachedQueryResults.

Throws:
DatabaseException

getContainerPolicy

public org.eclipse.persistence.internal.queries.ContainerPolicy getContainerPolicy()
PUBLIC: Return the query's ContainerPolicy.

Returns:
org.eclipse.persistence.internal.queries.ContainerPolicy

isDataReadQuery

public boolean isDataReadQuery()
PUBLIC: Return if this is a data read query.

Overrides:
isDataReadQuery in class DatabaseQuery

prepare

protected void prepare()
INTERNAL: Prepare the receiver for execution in a session.

Overrides:
prepare in class ReadQuery

prepareForExecution

public void prepareForExecution()
                         throws QueryException
INTERNAL: Prepare the receiver for execution in a session.

Overrides:
prepareForExecution in class ReadQuery
Throws:
QueryException

remoteExecute

public java.lang.Object remoteExecute()
INTERNAL:

Overrides:
remoteExecute in class DatabaseQuery

setContainerPolicy

public void setContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy)
PUBLIC: Set the container policy.


useCollectionClass

public void useCollectionClass(java.lang.Class concreteClass)
PUBLIC: Configure the query to use an instance of the specified container class to hold the target objects. The container class must implement (directly or indirectly) the Collection interface.


useCursoredStream

public void useCursoredStream()
PUBLIC: Use a CursoredStream as the result collection. The initial read size is 10 and page size is 5.


getResultType

public int getResultType()
Return the result type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, DatabaseRecord).

See Also:
ResultType

setResultType

public void setResultType(int resultType)
Set the result type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, DatabaseRecord).


setResultType

public void setResultType(java.lang.String resultType)
Set the result type to be configured, Map, Array, Value, Attribute (Map is the default, DatabaseRecord).

See Also:
ResultType

useCursoredStream

public void useCursoredStream(int initialReadSize,
                              int pageSize)
PUBLIC: Use a CursoredStream as the result collection.

Parameters:
initialReadSize - the initial number of objects to read
pageSize - the number of objects to read when more objects are needed from the database

useCursoredStream

public void useCursoredStream(int initialReadSize,
                              int pageSize,
                              ValueReadQuery sizeQuery)
PUBLIC: Use a CursoredStream as the result collection.

Parameters:
initialReadSize - the initial number of objects to read
pageSize - the number of objects to read when more objects are needed from the database
sizeQuery - a query that will return the size of the result set; this must be set if an expression is not used (i.e. custom SQL)

useScrollableCursor

public void useScrollableCursor()
PUBLIC: Use a ScrollableCursor as the result collection.


useScrollableCursor

public void useScrollableCursor(int pageSize)
PUBLIC: Use a ScrollableCursor as the result collection.

Parameters:
pageSize - the number of elements to be read into a the cursor when more elements are needed from the database.

useScrollableCursor

public void useScrollableCursor(ScrollableCursorPolicy policy)
PUBLIC: Use a ScrollableCursor as the result collection.

Parameters:
policy - the scrollable cursor policy allows for additional result set options. Example:

ScrollableCursorPolicy policy = new ScrollableCursorPolicy()

policy.setResultSetType(ScrollableCursorPolicy.TYPE_SCROLL_INSENSITIVE);

query.useScrollableCursor(policy);


EclipseLink 1.2.0, build 'v20091016-r5565' API Reference