public abstract class ReadQuery extends DatabaseQuery
Purpose: Abstract class for all read queries.
Responsibilities:
DatabaseQuery.ParameterType
Modifier and Type | Field and Description |
---|---|
protected int |
fetchSize
Used to set statement fetch size
|
protected int |
firstResult
Used to start query results at a specific result
|
protected int |
maxResults
Stores the JPA maxResult settings for a NamedQuery
|
protected int |
maxRows
Used for retrieve limited rows through the query.
|
protected long |
queryId |
protected QueryResultsCachePolicy |
queryResultCachingPolicy
Used to specify how query results are cached
|
protected java.lang.Object |
temporaryCachedQueryResults
Optimization: temporarily stores cached query results while they are being built in a cloned query
|
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, redirector, session, sessionName, shouldBindAllParameters, shouldCacheStatement, shouldCloneCall, shouldMaintainCache, shouldPrepare, shouldRetrieveBypassCache, shouldStoreBypassCache, shouldUseWrapperPolicy, shouldValidateUpdateCallCacheUse, sourceMapping, translationRow
Constructor and Description |
---|
ReadQuery()
PUBLIC:
Initialize the state of the query
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
buildObject(org.eclipse.persistence.internal.sessions.AbstractRecord row)
INTERNAL:
By default return the row.
|
void |
cacheQueryResults()
ADVANCED:
This method will instruct the query to cache the results returned by its
next execution.
|
abstract void |
cacheResult(java.lang.Object object)
INTERNAL:
This method is called by the object builder when building an original.
|
void |
clearQueryResults(org.eclipse.persistence.internal.sessions.AbstractSession session)
PUBLIC:
Clears the current cached results, the next execution with
read from the database.
|
protected void |
clonedQueryExecutionComplete(DatabaseQuery query,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL
Used to give the subclasses opportunity to copy aspects of the cloned query
to the original query.
|
void |
copyFromQuery(DatabaseQuery query)
INTERNAL:
Copy all setting from the query.
|
void |
doNotCacheQueryResults()
ADVANCED:
This method will instruct the query not to cache results.
|
int |
getFetchSize()
PUBLIC:
Return the fetchSize setting that this query will set on the JDBC Statement
NB - a value of zero means that no call to statement.setFetchSize() will be made.
|
int |
getFirstResult()
PUBLIC:
Return the value that will be set for the firstResult in the returned result set
|
int |
getInternalMax()
INTERNAL:
returns the JPA max results that may have been set on a NamedQuery
|
int |
getMaxRows()
PUBLIC:
Return the limit for the maximum number of rows that any ResultSet can contain to the given number.
|
long |
getQueryId()
INTERNAL:
This method is used to get the time in millis that this query is being executed at.
|
protected java.lang.Object |
getQueryResults(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
To any user of this object with some knowledge of what the query's results may contain.
|
protected java.lang.Object |
getQueryResults(org.eclipse.persistence.internal.sessions.AbstractSession session,
org.eclipse.persistence.internal.sessions.AbstractRecord row,
boolean checkExpiry)
INTERNAL:
To any user of this object with some knowledge of what the query's results may contain.
|
protected java.lang.Object |
getQueryResults(org.eclipse.persistence.internal.sessions.AbstractSession session,
boolean checkExpiry)
INTERNAL:
To any user of this object with some knowledge of what the query's results may contain.
|
QueryResultsCachePolicy |
getQueryResultsCachePolicy()
PUBLIC:
Return the QueryResultsCachePolicy for this query.
|
java.lang.Object |
getTemporaryCachedQueryResults()
INTERNAL:
Get results from the remporary cache.
|
boolean |
isDefaultPropertiesQuery()
INTERNAL:
Return true if the query uses default properties.
|
boolean |
isReadQuery()
PUBLIC:
Return if this is a read query.
|
protected void |
prepare()
INTERNAL:
This is different from 'prepareForExecution' in that this is called on the original query,
and the other is called on the copy of the query.
|
void |
prepareForExecution()
INTERNAL:
Prepare the receiver for execution in a session.
|
java.lang.Object |
remoteExecute(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Return if this is a read query.
|
void |
setFetchSize(int fetchSize)
PUBLIC:
Set the fetchSize setting that this query will set on the JDBC Statement
NB - a value of zero means that no call to statement.setFetchSize() will be made.
|
void |
setFirstResult(int firstResult)
PUBLIC:
Used to set the first result in any result set that is returned for this query.
|
void |
setInternalMax(int max)
INTERNAL:
sets the JPA max results that may have been set on a NamedQuery
|
void |
setMaxRows(int maxRows)
PUBLIC:
Used to set the limit for the maximum number of rows that any ResultSet can contain to the given number.
|
void |
setQueryId(long id)
INTERNAL:
This method is used to set the current system time in millis that this query is being executed at.
|
protected void |
setQueryResults(java.lang.Object resultFromQuery,
org.eclipse.persistence.internal.sessions.AbstractRecord row,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Set the cached results of the query.
|
void |
setQueryResultsCachePolicy(QueryResultsCachePolicy policy)
Set the QueryResultsCachePolicy.
|
void |
setTemporaryCachedQueryResults(java.lang.Object queryResults)
INTERNAL:
Put results in the temporary cache.
|
boolean |
shouldCacheQueryResults()
PUBLIC:
Return if the query should cache the results of the next execution or not.
|
addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgumentByTypeName, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, buildArgumentFields, buildSelectionCriteria, cacheStatement, cascadeAllParts, cascadeByMapping, cascadeOnlyDependentParts, cascadePrivateParts, checkDescriptor, checkEarlyReturn, checkForCustomQuery, checkPrepare, checkPrepare, clone, convertClassNamesToClasses, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, execute, executeDatabaseQuery, 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, 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, isDataReadQuery, 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, remoteExecute, 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, setRedirector, setSelectionCriteria, setSession, setSessionName, setShouldBindAllParameters, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldRetrieveBypassCache, setShouldStoreBypassCache, setShouldUseWrapperPolicy, setShouldValidateUpdateCallCacheUse, setSourceMapping, setSQLStatement, setSQLString, setTranslationRow, shouldAllowNativeSQLQuery, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeByMapping, shouldCascadeOnlyDependentParts, shouldCascadeParts, shouldCascadePrivateParts, shouldCloneCall, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldPrepare, shouldRetrieveBypassCache, shouldStoreBypassCache, shouldUseWrapperPolicy, shouldValidateUpdateCallCacheUse, storeBypassCache, toString
protected int maxRows
protected int firstResult
protected long queryId
protected int fetchSize
protected QueryResultsCachePolicy queryResultCachingPolicy
protected transient java.lang.Object temporaryCachedQueryResults
protected int maxResults
public java.lang.Object buildObject(org.eclipse.persistence.internal.sessions.AbstractRecord row)
public void cacheQueryResults()
This method will instruct the query to cache the results returned by its next execution. All subsequent executions of this query will return this cached result set even if new query parameters are specified. This method provides a performance enhancement for queries known to always return the same result set. Oracle recommends that you use this method only for such queries.
To disable this behavior, call doNotCacheQueryResults()
or
setQueryResultsCachePolicy(org.eclipse.persistence.queries.QueryResultsCachePolicy)
passing in null.
public abstract void cacheResult(java.lang.Object object)
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.
protected void clonedQueryExecutionComplete(DatabaseQuery query, org.eclipse.persistence.internal.sessions.AbstractSession session)
clonedQueryExecutionComplete
in class DatabaseQuery
public void clearQueryResults(org.eclipse.persistence.internal.sessions.AbstractSession session)
public void doNotCacheQueryResults()
This method will instruct the query not to cache results. All subsequent executions return result sets according to the current configuration of query parameters. After calling this method, any previously cached result set will be discarded the next time the query is executed.
To enable this behavior, call cacheQueryResults()
or
setQueryResultsCachePolicy(org.eclipse.persistence.queries.QueryResultsCachePolicy)
passing in a valid QueryResultsCachePolicy.
public QueryResultsCachePolicy getQueryResultsCachePolicy()
QueryResultsCachePolicy
public int getFirstResult()
public long getQueryId()
public int getInternalMax()
public int getMaxRows()
public int getFetchSize()
protected java.lang.Object getQueryResults(org.eclipse.persistence.internal.sessions.AbstractSession session)
protected java.lang.Object getQueryResults(org.eclipse.persistence.internal.sessions.AbstractSession session, boolean checkExpiry)
protected java.lang.Object getQueryResults(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord row, boolean checkExpiry)
public java.lang.Object getTemporaryCachedQueryResults()
public boolean isDefaultPropertiesQuery()
isDefaultPropertiesQuery
in class DatabaseQuery
public boolean isReadQuery()
isReadQuery
in class DatabaseQuery
public void copyFromQuery(DatabaseQuery query)
copyFromQuery
in class DatabaseQuery
protected void prepare() throws QueryException
prepare
in class DatabaseQuery
QueryException
public void prepareForExecution() throws QueryException
prepareForExecution
in class DatabaseQuery
QueryException
public java.lang.Object remoteExecute(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DatabaseException
remoteExecute
in class DatabaseQuery
DatabaseException
public void setQueryResultsCachePolicy(QueryResultsCachePolicy policy)
QueryResultsCachePolicy
public void setFirstResult(int firstResult)
public void setQueryId(long id)
public void setInternalMax(int max)
public void setMaxRows(int maxRows)
public void setFetchSize(int fetchSize)
protected void setQueryResults(java.lang.Object resultFromQuery, org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session)
public boolean shouldCacheQueryResults()
public void setTemporaryCachedQueryResults(java.lang.Object queryResults)