java.lang.Object
org.eclipse.persistence.queries.DatabaseQuery
org.eclipse.persistence.queries.ReadQuery
org.eclipse.persistence.queries.DataReadQuery
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
DirectReadQuery
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.
- Since:
- TOPLink/Java 1.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.persistence.queries.DatabaseQuery
DatabaseQuery.ParameterType
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
An Object[] of values is returned for each row.static final int
A single value is returned for each row.static final int
Auto, a single value if a single field is selected, otherwise an Object[] (JPA default).protected ContainerPolicy
static final int
A Map (DatabaseRecord) is returned for each row.protected int
Allow return type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, i.e.static final int
A single value is returned.Fields inherited from class org.eclipse.persistence.queries.ReadQuery
allowQueryResultsCacheValidation, fetchSize, firstResult, maxResults, maxRows, queryId, queryResultCachingPolicy, temporaryCachedQueryResults
Fields inherited from class org.eclipse.persistence.queries.DatabaseQuery
accessors, allowNativeSQLQuery, argumentFields, argumentParameterTypes, arguments, argumentTypeNames, argumentTypes, argumentValues, BATCH_FETCH_PROPERTY, CascadeAggregateDelete, CascadeAllParts, CascadeByMapping, CascadeDependentParts, cascadePolicy, CascadePrivateParts, descriptor, descriptors, doNotRedirect, executionSession, flushOnExecute, hintString, isCustomQueryUsed, isExecutionClone, isNativeConnectionRequired, isPrepared, isUserDefined, isUserDefinedSQLCall, monitorName, name, NoCascading, nullableArguments, parameterDelimiter, partitioningPolicy, properties, queryMechanism, queryTimeout, queryTimeoutUnit, redirector, session, sessionName, shouldBindAllParameters, shouldCacheStatement, shouldCloneCall, shouldMaintainCache, shouldPrepare, shouldRetrieveBypassCache, shouldReturnGeneratedKeys, shouldStoreBypassCache, shouldUseWrapperPolicy, shouldValidateUpdateCallCacheUse, sourceMapping, translationRow
-
Constructor Summary
ConstructorDescriptionPUBLIC: Initialize the state of the query.DataReadQuery
(String sqlString) PUBLIC: Initialize the query to use the specified SQL string.DataReadQuery
(Call call) PUBLIC: Initialize the query to use the specified call. -
Method Summary
Modifier and TypeMethodDescriptionINTERNAL: Build the result value for the row.void
cacheResult
(Object results) INTERNAL:clone()
INTERNAL: Clone the query.execute
(AbstractSession session, AbstractRecord row) INTERNAL: Execute the query.INTERNAL: Execute the query.protected Object
INTERNAL: The results are *not* in a cursor, build the collection.PUBLIC: Return the query's ContainerPolicy.int
Return the result type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, DatabaseRecord).INTERNAL: Conversion not supported.boolean
PUBLIC: Return if this is a data read query.protected void
prepare()
INTERNAL: Prepare the receiver for execution in a session.void
INTERNAL: Prepare the receiver for execution in a session.INTERNAL: Used by RemoteSession.void
setContainerPolicy
(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
(String resultType) Set the result type to be configured, Map, Array, Value, Attribute (Map is the default, DatabaseRecord).void
useCollectionClass
(Class<?> concreteClass) PUBLIC: Configure the query to use an instance of the specified container class to hold the target objects.void
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
PUBLIC: Use a ScrollableCursor as the result collection.void
useScrollableCursor
(int pageSize) PUBLIC: Use a ScrollableCursor as the result collection.void
PUBLIC: Use a ScrollableCursor as the result collection.Methods inherited from class org.eclipse.persistence.queries.ReadQuery
cacheQueryResults, clearQueryResults, clonedQueryExecutionComplete, copyFromQuery, doNotCacheQueryResults, getFetchSize, getFirstResult, getInternalMax, getMaxRows, getQueryId, getQueryResults, getQueryResults, getQueryResults, getQueryResultsCachePolicy, getTemporaryCachedQueryResults, isDefaultPropertiesQuery, isReadQuery, remoteExecute, setAllowQueryResultsCacheValidation, setFetchSize, setFirstResult, setInternalMax, setMaxRows, setQueryId, setQueryResults, setQueryResultsCachePolicy, setTemporaryCachedQueryResults, shouldAllowQueryResultsCacheValidation, shouldCacheQueryResults
Methods inherited from class org.eclipse.persistence.queries.DatabaseQuery
addArgument, addArgument, addArgument, 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, getAccessors, getArgumentParameterTypes, getArguments, getArgumentTypeNames, getArgumentTypes, getArgumentValues, getBatchObjects, getCall, getCascadePolicy, getDatasourceCall, getDatasourceCalls, getDefaultRedirector, getDescriptor, getDescriptors, getDomainClassNounName, getDoNotRedirect, getEJBQLString, getExecutionSession, getFlushOnExecute, getHintString, getJPQLString, getMonitorName, getName, getNullableArguments, getParameterDelimiter, getParameterDelimiterChar, getPartitioningPolicy, getProperties, getProperty, getQueryMechanism, getQueryNounName, getQueryTimeout, getQueryTimeoutUnit, getRedirector, getRedirectorForQuery, getReferenceClass, getReferenceClassName, getSelectionCriteria, getSensorName, getSession, getSessionName, getShouldBindAllParameters, getSourceMapping, getSQLStatement, getSQLString, getSQLStrings, getTranslatedSQLString, getTranslatedSQLStrings, getTranslationRow, hasAccessor, hasArguments, hasNullableArguments, 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, isResultSetMappingQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isUserDefinedSQLCall, isValueReadQuery, isWriteObjectQuery, maintainCache, prepareCall, prepareCustomQuery, prepareForRemoteExecution, prepareFromQuery, prepareInternal, redirectQuery, removeProperty, replaceValueHoldersIn, resetMonitorName, retrieveBypassCache, rowFromArguments, setAccessor, setAccessors, setAllowNativeSQLQuery, setArguments, setArgumentTypeNames, setArgumentTypes, setArgumentValues, setBatchObjects, setCall, setCascadePolicy, setDatasourceCall, setDescriptor, setDoNotRedirect, setEJBQLString, setExecutionSession, setFlushOnExecute, setHintString, setIsCustomQueryUsed, setIsExecutionClone, setIsNativeConnectionRequired, setIsPrepared, setIsUserDefined, setIsUserDefinedSQLCall, setJPQLString, setName, setNullableArguments, setParameterDelimiter, setPartitioningPolicy, setProperties, setProperty, setQueryMechanism, setQueryTimeout, setQueryTimeoutUnit, setRedirector, setSelectionCriteria, setSession, setSessionName, setShouldBindAllParameters, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldRetrieveBypassCache, setShouldReturnGeneratedKeys, setShouldStoreBypassCache, setShouldUseWrapperPolicy, setShouldValidateUpdateCallCacheUse, setSourceMapping, setSQLStatement, setSQLString, setTranslationRow, shouldAllowNativeSQLQuery, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeByMapping, shouldCascadeOnlyDependentParts, shouldCascadeParts, shouldCascadePrivateParts, shouldCloneCall, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldPrepare, shouldRetrieveBypassCache, shouldReturnGeneratedKeys, shouldStoreBypassCache, shouldUseWrapperPolicy, shouldValidateUpdateCallCacheUse, storeBypassCache, toString
-
Field Details
-
containerPolicy
-
resultType
protected int resultTypeAllow return type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, i.e. DatabaseRecord). -
MAP
public static final int MAPA Map (DatabaseRecord) is returned for each row.- See Also:
-
ARRAY
public static final int ARRAYAn Object[] of values is returned for each row.- See Also:
-
VALUE
public static final int VALUEA single value is returned.- See Also:
-
ATTRIBUTE
public static final int ATTRIBUTEA single value is returned for each row.- See Also:
-
AUTO
public static final int AUTOAuto, a single value if a single field is selected, otherwise an Object[] (JPA default).- See Also:
-
-
Constructor Details
-
DataReadQuery
public DataReadQuery()PUBLIC: Initialize the state of the query. -
DataReadQuery
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: Initialize the query to use the specified call.
-
-
Method Details
-
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.
- Specified by:
cacheResult
in classReadQuery
-
clone
INTERNAL: Clone the query.- Overrides:
clone
in classDatabaseQuery
-
execute
INTERNAL: Execute the query. If there are cached results return those. This must override the super to support result caching.- Overrides:
execute
in classDatabaseQuery
- Parameters:
session
- - the session in which the receiver will be executed.- Returns:
- An object or collection, the result of executing the query.
- Throws:
DatabaseException
- - an error has occurred on the database
-
executeDatabaseQuery
INTERNAL: Execute the query. Perform the work to execute the SQL string.- Specified by:
executeDatabaseQuery
in classDatabaseQuery
- Returns:
- a collection or cursor of Records representing the result set
- Throws:
DatabaseException
- an error has occurred on the database
-
getValueConverter
INTERNAL: Conversion not supported. -
buildObject
INTERNAL: Build the result value for the row.- Overrides:
buildObject
in classReadQuery
-
executeNonCursor
INTERNAL: The results are *not* in a cursor, build the collection. Cache the results in temporaryCachedQueryResults.- Throws:
DatabaseException
-
getContainerPolicy
PUBLIC: Return the query's ContainerPolicy. -
isDataReadQuery
public boolean isDataReadQuery()PUBLIC: Return if this is a data read query.- Overrides:
isDataReadQuery
in classDatabaseQuery
-
prepare
protected void prepare()INTERNAL: Prepare the receiver for execution in a session. -
prepareForExecution
INTERNAL: Prepare the receiver for execution in a session.- Overrides:
prepareForExecution
in classReadQuery
- Throws:
QueryException
-
remoteExecute
INTERNAL: Used by RemoteSession.- Overrides:
remoteExecute
in classDatabaseQuery
-
setContainerPolicy
PUBLIC: Set the container policy. -
useCollectionClass
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:
-
setResultType
public void setResultType(int resultType) Set the result type to be configured, MAP, ARRAY, VALUE, ATTRIBUTE (MAP is the default, DatabaseRecord). -
setResultType
Set the result type to be configured, Map, Array, Value, Attribute (Map is the default, DatabaseRecord).- See Also:
-
useCursoredStream
public void useCursoredStream(int initialReadSize, int pageSize) PUBLIC: Use a CursoredStream as the result collection.- Parameters:
initialReadSize
- the initial number of objects to readpageSize
- the number of objects to read when more objects are needed from the database
-
useCursoredStream
PUBLIC: Use a CursoredStream as the result collection.- Parameters:
initialReadSize
- the initial number of objects to readpageSize
- the number of objects to read when more objects are needed from the databasesizeQuery
- 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: 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);
-