Module org.eclipse.persistence.core
Package org.eclipse.persistence.queries
Class ResultSetMappingQuery
- java.lang.Object
-
- org.eclipse.persistence.queries.DatabaseQuery
-
- org.eclipse.persistence.queries.ReadQuery
-
- org.eclipse.persistence.queries.ObjectBuildingQuery
-
- org.eclipse.persistence.queries.ResultSetMappingQuery
-
- All Implemented Interfaces:
Serializable,Cloneable
public class ResultSetMappingQuery extends ObjectBuildingQuery
Purpose: Concrete class to perform read using raw SQL and the SQLResultSetMapping.
Responsibilities: Execute a selecting raw SQL string. Returns a List of results. Each item in the list will be another list consisting of the expected populated return types in the order they were specified in the SQLResultSetMapping
- Since:
- TopLink Java Essentials
- Author:
- Gordon Yorke
- See Also:
SQLResultSetMapping, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.persistence.queries.DatabaseQuery
DatabaseQuery.ParameterType
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanisExecuteCallprotected VectorresultRowsprotected List<String>resultSetMappingNamesprotected List<SQLResultSetMapping>resultSetMappingsprotected booleanreturnNameValuePairs-
Fields inherited from class org.eclipse.persistence.queries.ObjectBuildingQuery
DEFAULT_LOCK_MODE, executionTime, isCacheCheckComplete, LOCK, LOCK_NOWAIT, LOCK_RESULT_PROPERTY, lockingClause, NO_LOCK, prefetchedCacheKeys, printInnerJoinInWhereClause, referenceClass, referenceClassName, requiresDeferredLocks, shouldBuildNullForNullPk, shouldRefreshIdentityMapResult, shouldRefreshRemoteIdentityMapResult, shouldRegisterResultsInUnitOfWork, shouldUseExclusiveConnection, wasDefaultLockMode
-
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
Constructors Constructor Description ResultSetMappingQuery()PUBLIC: Initialize the state of the query.ResultSetMappingQuery(Call call)PUBLIC: Initialize the query to use the specified call.ResultSetMappingQuery(Call call, String sqlResultSetMappingName)PUBLIC: Initialize the query to use the specified call and SQLResultSetMapping
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSQLResultSetMapping(SQLResultSetMapping resultSetMapping)PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database resultsvoidaddSQLResultSetMappingName(String name)PUBLIC: Add a SQLResultSetMapping that is used by this query to process the database results.ListbuildObjectsFromRecords(List databaseRecords)INTERNAL: This method is used to build the results.ListbuildObjectsFromRecords(List databaseRecords, int index)INTERNAL: This method is used to build the results with the SQLResultSetMapping at the given index.protected ListbuildObjectsFromRecords(List databaseRecords, SQLResultSetMapping mapping)INTERNAL: This method is used to build the results.voidcacheResult(Object unwrappedOriginal)INTERNAL:voidconvertClassNamesToClasses(ClassLoader classLoader)INTERNAL: Convert all the class-name-based settings in this ResultSetMapping to actual class-based settings.ObjectexecuteDatabaseQuery()INTERNAL: Executes the prepared query on the datastore.SQLResultSetMappinggetSQLResultSetMapping()PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database resultsStringgetSQLResultSetMappingName()PUBLIC: Return the result set mapping name.List<String>getSQLResultSetMappingNames()PUBLIC: Return the result set mapping name.List<SQLResultSetMapping>getSQLResultSetMappings()PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database resultsbooleanhasResultSetMappings()PUBLIC: Return true if there are results set mappings associated with this query.booleanisResultSetMappingQuery()PUBLIC: Return true if this is a result set mapping query.protected voidprepare()INTERNAL: Prepare the receiver for execution in a session.voidsetIsExecuteCall(boolean isExecuteCall)PUBLIC: Set to true if you the actual jdbc result set returned from query execution.voidsetShouldReturnNameValuePairs(boolean returnNameValuePairs)Set the flag that indicates whether or not to return populated DatabaseRecord(s) as opposed to raw data when an SQLResultSetMapping is not set.voidsetSQLResultSetMapping(SQLResultSetMapping resultSetMapping)PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database resultsvoidsetSQLResultSetMappingName(String name)PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database resultsvoidsetSQLResultSetMappingNames(List<String> names)PUBLIC: This will be the SQLResultvoidsetSQLResultSetMappings(List<SQLResultSetMapping> resultSetMappings)PUBLIC: This will be the SQLResultSetMappings that are used by this query to process the database resultsbooleanshouldReturnNameValuePairs()Indicates whether or not to return populated DatabaseRecord(s) as opposed to raw data when an SQLResultSetMapping is not set.-
Methods inherited from class org.eclipse.persistence.queries.ObjectBuildingQuery
clone, clonedQueryExecutionComplete, copyFromQuery, deepClone, dontRefreshIdentityMapResult, dontRefreshRemoteIdentityMapResult, getDataResults, getExecutionFetchGroup, getExecutionFetchGroup, getExecutionTime, getLoadGroup, getLockMode, getPrefetchedCacheKeys, getQueryPrimaryKey, getReferenceClass, getReferenceClassName, hasExecutionFetchGroup, hasPartialAttributeExpressions, isAttributeJoined, isCacheCheckComplete, isClonePessimisticLocked, isDefaultLock, isLockQuery, isObjectBuildingQuery, isRegisteringResults, postRegisterIndividualResult, prepareCustomQuery, prepareFromQuery, printInnerJoinInWhereClause, recordCloneForPessimisticLocking, refreshIdentityMapResult, refreshRemoteIdentityMapResult, registerIndividualResult, requiresDeferredLocks, setExecutionTime, setLockMode, setPrefetchedCacheKeys, setPrintInnerJoinInWhereClause, setReferenceClass, setReferenceClassName, setRequiresDeferredLocks, setShouldBuildNullForNullPk, setShouldRefreshIdentityMapResult, setShouldRefreshRemoteIdentityMapResult, setShouldRegisterResultsInUnitOfWork, setShouldUseExclusiveConnection, setWasDefaultLockMode, shouldBuildNullForNullPk, shouldReadAllMappings, shouldReadMapping, shouldRefreshIdentityMapResult, shouldRefreshRemoteIdentityMapResult, shouldRegisterResultsInUnitOfWork, shouldUseExclusiveConnection, shouldUseSerializedObjectPolicy, usesResultSetAccessOptimization, wasDefaultLockMode
-
Methods inherited from class org.eclipse.persistence.queries.ReadQuery
buildObject, cacheQueryResults, clearQueryResults, doNotCacheQueryResults, getFetchSize, getFirstResult, getInternalMax, getMaxRows, getQueryId, getQueryResults, getQueryResults, getQueryResults, getQueryResultsCachePolicy, getTemporaryCachedQueryResults, isDefaultPropertiesQuery, isReadQuery, prepareForExecution, 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, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, execute, 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, 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, isObjectLevelModifyQuery, isObjectLevelReadQuery, isPrepared, isReadAllQuery, isReadObjectQuery, isReportQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isUserDefinedSQLCall, isValueReadQuery, isWriteObjectQuery, maintainCache, prepareCall, prepareForRemoteExecution, 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, 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 Detail
-
isExecuteCall
protected boolean isExecuteCall
-
returnNameValuePairs
protected boolean returnNameValuePairs
-
resultRows
protected Vector resultRows
-
resultSetMappings
protected List<SQLResultSetMapping> resultSetMappings
-
-
Constructor Detail
-
ResultSetMappingQuery
public ResultSetMappingQuery()
PUBLIC: Initialize the state of the query.
-
ResultSetMappingQuery
public ResultSetMappingQuery(Call call)
PUBLIC: Initialize the query to use the specified call.
-
-
Method Detail
-
addSQLResultSetMapping
public void addSQLResultSetMapping(SQLResultSetMapping resultSetMapping)
PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database results
-
addSQLResultSetMappingName
public void addSQLResultSetMappingName(String name)
PUBLIC: Add a SQLResultSetMapping that is used by this query to process the database results.
-
cacheResult
public void cacheResult(Object unwrappedOriginal)
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:
cacheResultin classReadQuery
-
convertClassNamesToClasses
public void convertClassNamesToClasses(ClassLoader classLoader)
INTERNAL: Convert all the class-name-based settings in this ResultSetMapping to actual class-based settings. This method is used when converting a project that has been built with class names to a project with classes.- Overrides:
convertClassNamesToClassesin classObjectBuildingQuery
-
shouldReturnNameValuePairs
public boolean shouldReturnNameValuePairs()
Indicates whether or not to return populated DatabaseRecord(s) as opposed to raw data when an SQLResultSetMapping is not set.
-
setShouldReturnNameValuePairs
public void setShouldReturnNameValuePairs(boolean returnNameValuePairs)
Set the flag that indicates whether or not to return populated DatabaseRecord(s) as opposed to raw data when an SQLResultSetMapping is not set.
-
setSQLResultSetMapping
public void setSQLResultSetMapping(SQLResultSetMapping resultSetMapping)
PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database results
-
setSQLResultSetMappings
public void setSQLResultSetMappings(List<SQLResultSetMapping> resultSetMappings)
PUBLIC: This will be the SQLResultSetMappings that are used by this query to process the database results
-
setSQLResultSetMappingName
public void setSQLResultSetMappingName(String name)
PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database results
-
setSQLResultSetMappingNames
public void setSQLResultSetMappingNames(List<String> names)
PUBLIC: This will be the SQLResult
-
buildObjectsFromRecords
public List buildObjectsFromRecords(List databaseRecords)
INTERNAL: This method is used to build the results. Interpreting the SQLResultSetMapping(s).
-
buildObjectsFromRecords
public List buildObjectsFromRecords(List databaseRecords, int index)
INTERNAL: This method is used to build the results with the SQLResultSetMapping at the given index.
-
buildObjectsFromRecords
protected List buildObjectsFromRecords(List databaseRecords, SQLResultSetMapping mapping)
INTERNAL: This method is used to build the results. Interpreting the SQLResultSetMapping.
-
executeDatabaseQuery
public Object executeDatabaseQuery() throws DatabaseException
INTERNAL: Executes the prepared query on the datastore.- Specified by:
executeDatabaseQueryin classDatabaseQuery- Returns:
- - the result of executing the query.
- Throws:
DatabaseException- - an error has occurred on the database.
-
hasResultSetMappings
public boolean hasResultSetMappings()
PUBLIC: Return true if there are results set mappings associated with this query.
-
isResultSetMappingQuery
public boolean isResultSetMappingQuery()
PUBLIC: Return true if this is a result set mapping query.- Overrides:
isResultSetMappingQueryin classDatabaseQuery
-
prepare
protected void prepare()
INTERNAL: Prepare the receiver for execution in a session.
-
getSQLResultSetMapping
public SQLResultSetMapping getSQLResultSetMapping()
PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database results
-
getSQLResultSetMappings
public List<SQLResultSetMapping> getSQLResultSetMappings()
PUBLIC: This will be the SQLResultSetMapping that is used by this query to process the database results
-
getSQLResultSetMappingName
public String getSQLResultSetMappingName()
PUBLIC: Return the result set mapping name.
-
getSQLResultSetMappingNames
public List<String> getSQLResultSetMappingNames()
PUBLIC: Return the result set mapping name.
-
setIsExecuteCall
public void setIsExecuteCall(boolean isExecuteCall)
PUBLIC: Set to true if you the actual jdbc result set returned from query execution. This will unprepare the query in case it was executed previously for a getResultList() call instead (or vice versa)
-
-