Top Description Fields Constructors Methods
org.eclipse.persistence.queries

public Class DataReadQuery

extends ReadQuery
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.queries.DirectReadQuery
Imports
java.util.*, org.eclipse.persistence.internal.helper.*, org.eclipse.persistence.config.ResultType, org.eclipse.persistence.exceptions.*, org.eclipse.persistence.internal.queries.*, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, org.eclipse.persistence.mappings.converters.Converter

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.

Author
Yvon Lavoie
Since
TOPLink/Java 1.0

Field Summary

Modifier and TypeField and Description
public static final int
ARRAY

An Object[] of values is returned for each row.

public static final int
ATTRIBUTE

A single value is returned for each row.

public static final int
AUTO

Auto, a single value if a single field is selected, otherwise an Object[] (JPA default).

protected ContainerPolicy
public static final 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. DatabaseRecord).

public static final int
VALUE

A single value is returned.

Inherited from org.eclipse.persistence.queries.ReadQuery:
allowQueryResultsCacheValidationfetchSizefirstResultmaxResultsmaxRowsqueryIdqueryResultCachingPolicytemporaryCachedQueryResults

Constructor Summary

AccessConstructor and Description
public
DataReadQuery()

PUBLIC: Initialize the state of the query.

public
DataReadQuery(String sqlString)

PUBLIC: Initialize the query to use the specified SQL string.

public
DataReadQuery(Call call)

PUBLIC: Initialize the query to use the specified call.

Method Summary

Modifier and TypeMethod and Description
public Object
buildObject(AbstractRecord row)

Overrides org.eclipse.persistence.queries.ReadQuery.buildObject.

INTERNAL: Build the result value for the row.
public void
cacheResult(Object results)

Implements abstract org.eclipse.persistence.queries.ReadQuery.cacheResult.

INTERNAL:

This method is called by the object builder when building an original.

public Object
clone()

Overrides org.eclipse.persistence.queries.DatabaseQuery.clone.

INTERNAL: Clone the query.
public Object

Returns:

An object or collection, the result of executing the query.
execute
(AbstractSession
- the session in which the receiver will be executed.
session
,
AbstractRecord row)

Overrides org.eclipse.persistence.queries.DatabaseQuery.execute.

INTERNAL: Execute the query.
public Object

Returns:

a collection or cursor of Records representing the result set
executeDatabaseQuery
()

Implements abstract org.eclipse.persistence.queries.DatabaseQuery.executeDatabaseQuery.

INTERNAL: Execute the query.
protected Object
executeNonCursor()

INTERNAL: The results are *not* in a cursor, build the collection.

public ContainerPolicy
getContainerPolicy()

PUBLIC: Return the query's ContainerPolicy.

public int
getResultType()

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

public Converter
getValueConverter()

INTERNAL: Conversion not supported.

public boolean
isDataReadQuery()

Overrides org.eclipse.persistence.queries.DatabaseQuery.isDataReadQuery.

PUBLIC: Return if this is a data read query.
protected void
prepare()

Overrides org.eclipse.persistence.queries.ReadQuery.prepare.

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

Overrides org.eclipse.persistence.queries.ReadQuery.prepareForExecution.

INTERNAL: Prepare the receiver for execution in a session.
public Object
public void
setContainerPolicy(ContainerPolicy containerPolicy)

PUBLIC: Set the container policy.

public void
setResultType(int resultType)

Set the result type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, DatabaseRecord).

public void
setResultType(String resultType)

Set the result type to be configured, Map, Array, Value, Attribute (Map is the default, DatabaseRecord).

public void
useCollectionClass(Class<?> concreteClass)

PUBLIC: Configure the query to use an instance of the specified container class to hold the target objects.

public void
useCursoredStream()

PUBLIC: Use a CursoredStream as the result collection.

public void
useCursoredStream(int
the initial number of objects to read
initialReadSize
,
int
the number of objects to read when more objects are needed from the database
pageSize
)

PUBLIC: Use a CursoredStream as the result collection.

public void
useCursoredStream(int
the initial number of objects to read
initialReadSize
,
int
the number of objects to read when more objects are needed from the database
pageSize
,
ValueReadQuery
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)
sizeQuery
)

PUBLIC: Use a CursoredStream as the result collection.

public void
useScrollableCursor()

PUBLIC: Use a ScrollableCursor as the result collection.

public void
useScrollableCursor(int
the number of elements to be read into a the cursor when more elements are needed from the database.
pageSize
)

PUBLIC: Use a ScrollableCursor as the result collection.

public void
useScrollableCursor(ScrollableCursorPolicy
the scrollable cursor policy allows for additional result set options. Example:

ScrollableCursorPolicy policy = new ScrollableCursorPolicy()

policy.setResultSetType(ScrollableCursorPolicy.TYPE_SCROLL_INSENSITIVE);

query.useScrollableCursor(policy);

policy
)

PUBLIC: Use a ScrollableCursor as the result collection.

Inherited from org.eclipse.persistence.queries.ReadQuery:
cacheQueryResultsclearQueryResultsclonedQueryExecutionCompletecopyFromQuerydoNotCacheQueryResultsgetFetchSizegetFirstResultgetInternalMaxgetMaxRowsgetQueryIdgetQueryResultsgetQueryResultsgetQueryResultsgetQueryResultsCachePolicygetTemporaryCachedQueryResultsisDefaultPropertiesQueryisReadQueryremoteExecutesetAllowQueryResultsCacheValidationsetFetchSizesetFirstResultsetInternalMaxsetMaxRowssetQueryIdsetQueryResultssetQueryResultsCachePolicysetTemporaryCachedQueryResultsshouldAllowQueryResultsCacheValidationshouldCacheQueryResults

Field Detail

ARRAYback to summary
public static final int ARRAY

An Object[] of values is returned for each row.

ATTRIBUTEback to summary
public static final int ATTRIBUTE

A single value is returned for each row.

AUTOback to summary
public static final int AUTO

Auto, a single value if a single field is selected, otherwise an Object[] (JPA default).

containerPolicyback to summary
protected ContainerPolicy containerPolicy
MAPback to summary
public static final int MAP

A Map (DatabaseRecord) is returned for each row.

resultTypeback to summary
protected int resultType

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

VALUEback to summary
public static final int VALUE

A single value is returned.

Constructor Detail

DataReadQueryback to summary
public DataReadQuery()

PUBLIC: Initialize the state of the query.

DataReadQueryback to summary
public DataReadQuery(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.

DataReadQueryback to summary
public DataReadQuery(Call call)

PUBLIC: Initialize the query to use the specified call.

Method Detail

buildObjectback to summary
public Object buildObject(AbstractRecord row)

Overrides org.eclipse.persistence.queries.ReadQuery.buildObject.

INTERNAL: Build the result value for the row.

Annotations
@Override
cacheResultback to summary
public void cacheResult(Object results)

Implements abstract org.eclipse.persistence.queries.ReadQuery.cacheResult.

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.

Annotations
@Override
cloneback to summary
public Object clone()

Overrides org.eclipse.persistence.queries.DatabaseQuery.clone.

INTERNAL: Clone the query.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
executeback to summary
public Object execute(AbstractSession session, AbstractRecord row) throws DatabaseException

Overrides org.eclipse.persistence.queries.DatabaseQuery.execute.

INTERNAL: Execute the query. If there are cached results return those. This must override the super to support result caching.

Parameters
session:AbstractSession

- the session in which the receiver will be executed.

Returns:Object

An object or collection, the result of executing the query.

Annotations
@Override
Exceptions
DatabaseException:
- an error has occurred on the database
executeDatabaseQueryback to summary
public Object executeDatabaseQuery() throws DatabaseException

Implements abstract org.eclipse.persistence.queries.DatabaseQuery.executeDatabaseQuery.

INTERNAL: Execute the query. Perform the work to execute the SQL string.

Returns:Object

a collection or cursor of Records representing the result set

Annotations
@Override
Exceptions
DatabaseException:
an error has occurred on the database
executeNonCursorback to summary
protected Object executeNonCursor() throws DatabaseException

INTERNAL: The results are *not* in a cursor, build the collection. Cache the results in temporaryCachedQueryResults.

getContainerPolicyback to summary
public ContainerPolicy getContainerPolicy()

PUBLIC: Return the query's ContainerPolicy.

getResultTypeback to summary
public int getResultType()

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

See Also
ResultType
getValueConverterback to summary
public Converter getValueConverter()

INTERNAL: Conversion not supported.

isDataReadQueryback to summary
public boolean isDataReadQuery()

Overrides org.eclipse.persistence.queries.DatabaseQuery.isDataReadQuery.

PUBLIC: Return if this is a data read query.

Annotations
@Override
prepareback to summary
protected void prepare()

Overrides org.eclipse.persistence.queries.ReadQuery.prepare.

INTERNAL: Prepare the receiver for execution in a session.

Annotations
@Override
prepareForExecutionback to summary
public void prepareForExecution() throws QueryException

Overrides org.eclipse.persistence.queries.ReadQuery.prepareForExecution.

INTERNAL: Prepare the receiver for execution in a session.

Annotations
@Override
remoteExecuteback to summary
public Object remoteExecute()

Overrides org.eclipse.persistence.queries.DatabaseQuery.remoteExecute.

INTERNAL: Used by RemoteSession.

Annotations
@Override
setContainerPolicyback to summary
public void setContainerPolicy(ContainerPolicy containerPolicy)

PUBLIC: Set the container policy.

setResultTypeback to summary
public void setResultType(int resultType)

Set the result type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, DatabaseRecord).

setResultTypeback to summary
public void setResultType(String resultType)

Set the result type to be configured, Map, Array, Value, Attribute (Map is the default, DatabaseRecord).

See Also
ResultType
useCollectionClassback to summary
public void useCollectionClass(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.

useCursoredStreamback to summary
public void useCursoredStream()

PUBLIC: Use a CursoredStream as the result collection. The initial read size is 10 and page size is 5.

useCursoredStreamback to summary
public void useCursoredStream(int initialReadSize, int pageSize)

PUBLIC: Use a CursoredStream as the result collection.

Parameters
initialReadSize:int

the initial number of objects to read

pageSize:int

the number of objects to read when more objects are needed from the database

useCursoredStreamback to summary
public void useCursoredStream(int initialReadSize, int pageSize, ValueReadQuery sizeQuery)

PUBLIC: Use a CursoredStream as the result collection.

Parameters
initialReadSize:int

the initial number of objects to read

pageSize:int

the number of objects to read when more objects are needed from the database

sizeQuery:ValueReadQuery

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)

useScrollableCursorback to summary
public void useScrollableCursor()

PUBLIC: Use a ScrollableCursor as the result collection.

useScrollableCursorback to summary
public void useScrollableCursor(int pageSize)

PUBLIC: Use a ScrollableCursor as the result collection.

Parameters
pageSize:int

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

useScrollableCursorback to summary
public void useScrollableCursor(ScrollableCursorPolicy policy)

PUBLIC: Use a ScrollableCursor as the result collection.

Parameters
policy:ScrollableCursorPolicy

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

ScrollableCursorPolicy policy = new ScrollableCursorPolicy()

policy.setResultSetType(ScrollableCursorPolicy.TYPE_SCROLL_INSENSITIVE);

query.useScrollableCursor(policy);