Class ObjectLevelReadQuery
- java.lang.Object
-
- org.eclipse.persistence.queries.DatabaseQuery
-
- org.eclipse.persistence.queries.ReadQuery
-
- org.eclipse.persistence.queries.ObjectBuildingQuery
-
- org.eclipse.persistence.queries.ObjectLevelReadQuery
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
ReadAllQuery,ReadObjectQuery
public abstract class ObjectLevelReadQuery extends ObjectBuildingQuery
Purpose: Abstract class for all read queries using objects.
Description: Contains common behavior for all read queries using objects.
- See Also:
- Serialized Form
- Author:
- Yvon Lavoie
- Since:
- TOPLink/Java 1.0
-
-
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 java.util.List<java.lang.Object>additionalFieldsAllow for additional fields to be selected, used for m-m batch reading.protected java.util.Map<DatabaseMapping,ObjectLevelReadQuery>aggregateQueriesAllow aggregate queries to be prepared and cached.protected BatchFetchPolicybatchFetchPolicyDefines batch fetching configuration.protected intcacheUsageAllow for the cache usage to be specified to enable in-memory querying.static intCheckCacheByExactPrimaryKeystatic intCheckCacheByPrimaryKeystatic intCheckCacheOnlystatic intCheckCacheThenDatabaseprotected java.util.Map<java.lang.Class,org.eclipse.persistence.internal.databaseaccess.DatabaseCall>concreteSubclassCallsAllow concrete subclasses calls to be prepared and cached for inheritance queries.protected java.util.Map<java.lang.Class,java.util.Map<DatabaseMapping,java.lang.Object>>concreteSubclassJoinedMappingIndexesAllow concrete subclasses joined mapping indexes to be prepared and cached for inheritance queries.protected java.util.Map<java.lang.Class,DatabaseQuery>concreteSubclassQueriesAllow concrete subclasses queries to be prepared and cached for inheritance queries.static intConformResultsInUnitOfWorkprotected ExpressionBuilderdefaultBuilderProvide a default builder so that it's easier to be consistentprotected shortdistinctStateIndicates if distinct should be used or not.static intDoNotCheckCachestatic shortDONT_USE_DISTINCTprotected FetchGroupfetchGroupFetchGroupspecified on this query.protected java.lang.StringfetchGroupNameName ofFetchGroupstored in theFetchGroupManagerof the reference class' descriptor or any of its parent descriptors.protected intinMemoryQueryIndirectionPolicyUsed to determine behavior of indirection in in-memory querying and conforming.protected booleanisCachedExpressionQueryIndicates whether the query is cached as an expression query in descriptor's query manager.protected booleanisPrePreparedAllow a prePrepare stage to build the expression for EJBQL and QBE and resolve joining.protected booleanisReadOnlyPERF: Allow queries to be defined as read-only in unit of work execution.protected java.lang.BooleanisReferenceClassLockedPERF: Caches locking policy isReferenceClassLocked setting.protected java.lang.BooleanisResultSetAccessOptimizedQueryPERF: Allow queries to build while accessing the database result-set.static booleanisResultSetAccessOptimizedQueryDefaultIf neither query specifies isResultSetOptimizedQuery nor session specifies shouldOptimizeResultSetAccess then this value is used to indicate whether optimization should be attemptedprotected booleanisResultSetOptimizedQueryPERF: Allow queries to build directly from the database result-set.protected org.eclipse.persistence.internal.queries.JoinedAttributeManagerjoinedAttributeManagerStores the helper object for dealing with joined attributesprotected LoadGrouploadGroupSpecifies indirection that should be instantiated before returning resultprotected java.lang.StringlockModeTypeUsed when specifying a lock mode for the querystatic java.lang.StringNONENames of the possible lock mode types, JPA 2.0 onlyprotected java.util.List<Expression>nonFetchJoinAttributeExpressionsStores the non fetchjoin attributes, these are joins that will be represented in the where clause but not in the select.static java.lang.StringOPTIMISTICstatic java.lang.StringOPTIMISTIC_FORCE_INCREMENTprotected java.util.List<Expression>orderByExpressionsUsed for ordering support.protected java.util.List<Expression>partialAttributeExpressionsStores the partial attributes that have been added to this querystatic java.lang.StringPESSIMISTIC_static java.lang.StringPESSIMISTIC_FORCE_INCREMENTstatic java.lang.StringPESSIMISTIC_READstatic java.lang.StringPESSIMISTIC_WRITEstatic java.lang.StringREADNames of the possible lock mode types, JPA 1.0 and 2.0protected booleanshouldExtendPessimisticLockScopeIndicates whether pessimistic lock should also be applied to relation tables (ManyToMany and OneToOne mappings), reference tables (DirectCollection and AggregateCollection mapping).protected booleanshouldIncludeDataAllow for a complex result to be return including the rows and objects, used for m-m batch reading.protected java.lang.BooleanshouldOuterJoinSubclassesDefine if an outer join should be used to read subclasses.protected booleanshouldUseDefaultFetchGroupFlag to turn on/off the use of the default fetch group.protected booleanshouldUseSerializedObjectPolicyIndicates whether the query should use SerializedObjectPolicy if descriptor has it.static booleanshouldUseSerializedObjectPolicyDefaultdefault value for shouldUseSerializedObjectPolicystatic shortUNCOMPUTED_DISTINCTprotected java.util.List<Expression>unionExpressionsAllow a query's results to be unioned (UNION, INTERSECT, EXCEPT) with another query results.static shortUSE_DISTINCTstatic intUseDescriptorSettingprotected java.lang.BooleanusesResultSetAccessOptimizationPERF: Indicates whether the query is actually using ResultSet optimization.protected java.lang.IntegerwaitTimeoutwaitTimeout has three possible setting: null, 0 and 1..N null: use the session.getPessimisticLockTimeoutDefault() if available. 0: issue a LOCK_NOWAIT 1..N: use this value to set the WAIT clause.protected java.util.concurrent.TimeUnitwaitTimeoutUnitstatic java.lang.StringWRITE-
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 ObjectLevelReadQuery()INTERNAL: Initialize the state of the query
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidacquireLocks()PUBLIC: Set the query to lock, this will also turn refreshCache on.voidacquireLocksWithoutWaiting()PUBLIC: Set the query to lock without waiting (blocking), this will also turn refreshCache on.voidaddAdditionalField(Expression fieldExpression)INTERNAL: Additional fields can be added to a query.voidaddAdditionalField(org.eclipse.persistence.internal.helper.DatabaseField field)INTERNAL: Additional fields can be added to a query.voidaddBatchReadAttribute(java.lang.String attributeName)PUBLIC: Specify the foreign-reference mapped attribute to be optimized in this query.voidaddBatchReadAttribute(Expression attributeExpression)PUBLIC: Specify the foreign-reference mapped attribute to be optimized in this query.voidaddDescendingOrdering(java.lang.String queryKeyName)PUBLIC: Order the query results by the object's attribute or query key name.voidaddJoinedAttribute(java.lang.String attributeName)PUBLIC: Specify the relationship attribute to be join fetched in this query.voidaddJoinedAttribute(Expression attributeExpression)PUBLIC: Specify the attribute to be join fetched in this query.voidaddJoinSelectionFields(java.util.Vector fields, boolean isCustomSQL)INTERNAL: The method adds to the passed input vector the fields or expressions corresponding to the joins.voidaddNonFetchJoin(Expression target)PUBLIC: Specify the object expression to be joined in this query.voidaddNonFetchJoinedAttribute(java.lang.String attributeName)PUBLIC: Specify the relationship attribute to be join in this query.voidaddNonFetchJoinedAttribute(Expression attributeExpression)PUBLIC: Specify the relationship attribute to be join in this query.voidaddOrdering(Expression orderingExpression)PUBLIC: Add the ordering expression.voidaddPartialAttribute(java.lang.String attributeName)Deprecated.since EclipseLink 2.1, partial attributes replaced by fetch groups.voidaddPartialAttribute(Expression attributeExpression)Deprecated.since EclipseLink 2.1, partial attributes replaced by fetch groups.protected voidaddSelectionFieldsForJoinedExpression(java.util.List fields, boolean isCustomSQL, Expression expression)INTERNAL: The method adds to the passed input vector the fields or expressions corresponding to the passed join expression.voidaddUnionExpression(Expression union)PUBLIC: Add the union expression to the query.java.lang.ObjectbuildObject(org.eclipse.persistence.internal.sessions.AbstractRecord row)INTERNAL: Used to build the object, and register it if in the context of a unit of work.voidchangeDescriptor(org.eclipse.persistence.internal.sessions.AbstractSession theSession)INTERNAL: The reference class has been changed, need to reset the descriptor.voidcheckCacheOnly()PUBLIC: The cache will checked completely, if the object is not found null will be returned or an error if the query is too complex.protected abstract java.lang.BooleancheckCustomQueryFlag(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)INTERNAL: Check and return custom query flag.voidcheckDescriptor(org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Ensure that the descriptor has been set.java.lang.ObjectcheckEarlyReturn(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)INTERNAL: Check to see if this query already knows the return value without performing any further work.protected abstract java.lang.ObjectcheckEarlyReturnLocal(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)INTERNAL: Contains the body of the check early return call, implemented by subclasses.protected DatabaseQuerycheckForCustomQuery(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)INTERNAL: Check to see if a custom query should be used for this query.voidcheckPrepare(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow, boolean force)INTERNAL: Check to see if this query needs to be prepare and prepare it.voidcheckPrePrepare(org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: ObjectLevelReadQueries now have an explicit pre-prepare stage, which is for checking for pessimistic locking, and computing any joined attributes declared on the descriptor.voidclearIsResultSetOptimizedQuery()ADVANCED: Clear the flag set by setIsResultSetOptimizedQuery method, allow to use default set on the session instead.voidclearUsesResultSetAccessOptimization()INTERNAL:java.lang.Objectclone()INTERNAL: Creates and returns a copy of this query.voidcomputeBatchReadAttributes()INTERNAL: Compute the cache batched attributes.voidcomputeBatchReadMappingQueries()INTERNAL: Used to optimize joining by pre-computing the nested join queries for the mappings.protected voidcomputeNestedQueriesForBatchReadExpressions(java.util.List<Expression> batchReadExpressions)INTERNAL: This method is used when computing the nested queries for batch read mappings.protected java.lang.ObjectconformIndividualResult(java.lang.Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, org.eclipse.persistence.internal.sessions.AbstractRecord arguments, Expression selectionCriteriaClone, java.util.Map alreadyReturned)INTERNAL: Conforms and registers an individual result.voidconformResultsInUnitOfWork()PUBLIC: The cache will checked completely, if the object is not found the database will be queried, and the database result will be verified with what is in the cache and/or unit of work including new objects.voidcopyFromQuery(DatabaseQuery query)INTERNAL: Copy all setting from the query.java.lang.ObjectdeepClone()INTERNAL: Clone the query, including its selection criteria.voiddontAcquireLocks()PUBLIC: Set the query not to lock.voiddontCheckCache()PUBLIC: This can be used to explicitly disable the cache hit.voiddontRefreshIdentityMapResult()PUBLIC: When unset means perform read normally and dont do refresh.voiddontRefreshRemoteIdentityMapResult()PUBLIC: When unset means perform read normally and dont do refresh.voiddontUseDistinct()ADVANCED: If a distinct has been set the DISTINCT clause will be printed.booleanequals(java.lang.Object object)INTERNAL: Return if the query is equal to the other.voidexcept(ReportQuery query)PUBLIC: Except the query results with the other query.java.lang.Objectexecute(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)INTERNAL: Execute the query.java.lang.ObjectexecuteDatabaseQuery()INTERNAL: Executes the prepared query on the datastore.java.lang.ObjectexecuteInUnitOfWork(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)INTERNAL: Execute the query in the unit of work.protected abstract java.lang.ObjectexecuteObjectLevelReadQuery()Executes the prepared query on the datastore.protected abstract java.lang.ObjectexecuteObjectLevelReadQueryFromResultSet()Executes the prepared query on the datastore.voidextendPessimisticLockScope()INTERNAL: Extends pessimistic lock scope.java.util.List<java.lang.Object>getAdditionalFields()INTERNAL: Additional fields can be added to a query.java.util.Map<DatabaseMapping,ObjectLevelReadQuery>getAggregateQueries()INTERNAL: Return the cache of aggregate queries.ObjectLevelReadQuerygetAggregateQuery(DatabaseMapping mapping)INTERNAL: Return the aggregate query clone for the mapping.AsOfClausegetAsOfClause()ADVANCED: Answers the past time this query is as of.BatchFetchPolicygetBatchFetchPolicy()Return the batch fetch policy for configuring batch fetching.java.util.Map<java.lang.Object,java.lang.Object>getBatchObjects()INTERNAL: Return temporary map of batched objects.java.util.List<Expression>getBatchReadAttributeExpressions()INTERNAL: Return all attributes specified for batch reading.intgetCacheUsage()PUBLIC: Return the cache usage.java.util.Map<java.lang.Class,org.eclipse.persistence.internal.databaseaccess.DatabaseCall>getConcreteSubclassCalls()INTERNAL: Return the cache of concrete subclass calls.java.util.Map<java.lang.Class,java.util.Map<DatabaseMapping,java.lang.Object>>getConcreteSubclassJoinedMappingIndexes()INTERNAL: Return the cache of concrete subclass joined mapping indexes.java.util.Map<java.lang.Class,DatabaseQuery>getConcreteSubclassQueries()INTERNAL: Return the cache of concrete subclass queries.shortgetDistinctState()ADVANCED: If a distinct has been set the DISTINCT clause will be printed.java.lang.ObjectgetExampleObject()PUBLIC: This method returns the current example object.FetchGroupgetExecutionFetchGroup()INTERNAL: Returns FetchGroup that will be applied to the query.FetchGroupgetExecutionFetchGroup(ClassDescriptor descriptor)INTERNAL: Returns FetchGroup that will be applied to the query.ExpressionBuildergetExpressionBuilder()REQUIRED: Get the expression builder which should be used for this query.FetchGroupgetFetchGroup()Return the fetch group set in the query.java.lang.StringgetFetchGroupName()Return the fetch group name set in the query.java.util.Set<org.eclipse.persistence.internal.helper.DatabaseField>getFetchGroupNonNestedFieldsSet()INTERNAL: Return the set of fields required in the select clause, for fetch group reading.java.util.Set<org.eclipse.persistence.internal.helper.DatabaseField>getFetchGroupNonNestedFieldsSet(DatabaseMapping nestedMapping)INTERNAL: Return the set of fields required in the select clause, for fetch group reading.java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>getFetchGroupSelectionFields()INTERNAL: Return the fields required in the select clause, for fetch group reading.protected java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>getFetchGroupSelectionFields(DatabaseMapping nestedMapping)INTERNAL: Return the fields required in the select clause, for fetch group reading.InMemoryQueryIndirectionPolicygetInMemoryQueryIndirectionPolicy()PUBLIC: Returns the InMemoryQueryIndirectionPolicy for this queryintgetInMemoryQueryIndirectionPolicyState()PUBLIC: Returns the InMemoryQueryIndirectionPolicy for this queryjava.util.ListgetJoinedAttributeExpressions()INTERNAL: Convenience method for project mapping.org.eclipse.persistence.internal.queries.JoinedAttributeManagergetJoinedAttributeManager()INTERNAL: Return join manager responsible for managing all aspects of joining for the query.LoadGroupgetLoadGroup()Return the load group set in the query.org.eclipse.persistence.internal.expressions.ForUpdateClausegetLockingClause()INTERNAL: It is not exactly as simple as a query being either locking or not.java.lang.StringgetLockModeType()INTERNAL: returns the javax.persistence.LockModeType string value set on this query.java.util.List<Expression>getNonFetchJoinAttributeExpressions()INTERNAL: Return the attributes that must be joined, but not fetched, that is, do not trigger the value holder.java.util.List<Expression>getOrderByExpressions()INTERNAL: Return the order expressions for the query.java.util.List<Expression>getPartialAttributeExpressions()INTERNAL: Return the partial attributes to select.java.util.VectorgetPartialAttributeSelectionFields(boolean isCustomSQL)INTERNAL: Return the fields required in the select clause, for patial attribute reading.QueryByExamplePolicygetQueryByExamplePolicy()PUBLIC: When using Query By Example, an instance of QueryByExamplePolicy is used to customize the query.protected abstract ObjectLevelReadQuerygetReadQuery()INTERNAL: Get custom read query from query manager.java.lang.ClassgetReferenceClass()PUBLIC: Return the reference class of the query.java.lang.StringgetReferenceClassName()INTERNAL: Return the reference class of the query.java.util.VectorgetSelectionFields()INTERNAL: Return the fields selected by the query.java.util.List<Expression>getUnionExpressions()Return any union expressions.java.lang.IntegergetWaitTimeout()PUBLIC: Return the WAIT timeout value of pessimistic locking query.java.util.concurrent.TimeUnitgetWaitTimeoutUnit()booleanhasAdditionalFields()INTERNAL: Return if additional field.booleanhasAsOfClause()PUBLIC: Answers if the domain objects are to be read as of a past time.booleanhasBatchReadAttributes()INTERNAL: Return true is this query has batchingbooleanhasDefaultBuilder()INTERNAL: Checks to see if a builder has been set on the query.booleanhasExecutionFetchGroup()INTERNAL: Indicates whether a FetchGroup will be applied to the query.booleanhasFetchGroup()Return if a fetch group is set in the query.inthashCode()INTERNAL: Compute a consistent hash-code for the expression.booleanhasJoining()INTERNAL: Return if any attributes are joined.booleanhasNonFetchJoinedAttributeExpressions()INTERNAL: Return the attributes that must be joined.booleanhasOrderByExpressions()INTERNAL: The order bys are lazy initialized to conserve space.booleanhasPartialAttributeExpressions()INTERNAL: Return if partial attributes.booleanhasUnionExpressions()INTERNAL: The unions are lazy initialized to conserve space.protected voidinitializeDefaultBuilder()Initialize the expression builder which should be used for this query.voidintersect(ReportQuery query)PUBLIC: Intersect the query results with the other query.booleanisAttributeBatchRead(ClassDescriptor mappingDescriptor, java.lang.String attributeName)INTERNAL: Return if the attribute is specified for batch reading.booleanisCachedExpressionQuery()INTERNAL: Indicates whether the query is cached as an expression query in descriptor's query manager.booleanisClonePessimisticLocked(java.lang.Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)INTERNAL: Helper method that checks if clone has been locked with uow.booleanisDefaultLock()INTERNAL: Helper method to determine the default mode.booleanisDefaultPropertiesQuery()INTERNAL: Return true if the query uses default properties.booleanisDistinctComputed()INTERNAL: return true if this query has computed its distinct value alreadybooleanisLockQuery()PUBLIC: Answers if the query lock mode is known to be LOCK or LOCK_NOWAIT.booleanisLockQuery(Session session)ADVANCED: Answers if this query will issue any pessimistic locks.booleanisObjectLevelReadQuery()PUBLIC: Return if this is an object level read query.booleanisPartialAttribute(java.lang.String attributeName)INTERNAL: Return if partial attribute.protected booleanisPrePrepared()PUBLIC: Queries prepare common stated in themselves.booleanisPrimaryKeyQuery()INTERNAL: Return if the query is known to be by primary key.booleanisReadOnly()PUBLIC: Return if the query is read-only.protected booleanisReferenceClassLocked()INTERNAL: Cache the locking policy isReferenceClassLocked check.java.lang.BooleanisResultSetAccessOptimizedQuery()ADVANCED: Return if the query result set access should be optimized.booleanisResultSetOptimizedQuery()ADVANCED: Return if the query should be optimized to build directly from the result set.protected voidprepare()INTERNAL: Prepare the receiver for execution in a session.voidprepareFetchGroup()INTERNAL: Add mandatory attributes to fetch group, create entityFetchGroup.protected voidprepareForRemoteExecution()INTERNAL: Prepare the receiver for execution in a session.protected booleanprepareFromCachedQuery()INTERNAL: Check if the query is cached and prepare from it.voidprepareFromQuery(DatabaseQuery query)INTERNAL: Prepare the query from the prepared query.DatabaseQueryprepareOutsideUnitOfWork(org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: There is a very special case where a query may be a bean-level pessimistic locking query.protected voidprepareQuery()INTERNAL: Prepare the receiver for execution in a session.protected voidprepareResultSetAccessOptimization()INTERNAL: Sets usesResultSetAccessOptimization based on isResultSetAccessOptimizedQuery, session default and query settings that could not be altered without re-preparing the query.protected voidprePrepare()INTERNAL: Prepare the receiver for execution in a session.voidrecordCloneForPessimisticLocking(java.lang.Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)INTERNAL: Helper method that records clone with uow if query is pessimistic locking.voidrefreshIdentityMapResult()PUBLIC: Refresh the attributes of the object(s) resulting from the query.voidrefreshRemoteIdentityMapResult()PUBLIC: Refresh the attributes of the object(s) resulting from the query.abstract java.lang.ObjectregisterResultInUnitOfWork(java.lang.Object result, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, org.eclipse.persistence.internal.sessions.AbstractRecord arguments, boolean buildDirectlyFromRows)INTERNAL: All objects queried via a UnitOfWork get registered here.voidresetDistinct()ADVANCED: If a distinct has been set the DISTINCT clause will be printed.voidsetAdditionalFields(java.util.List<java.lang.Object> additionalFields)INTERNAL: Additional fields can be added to a query.voidsetAggregateQuery(DatabaseMapping mapping, ObjectLevelReadQuery query)INTERNAL: Set the aggregate query clone for the mapping.voidsetAsOfClause(AsOfClause pastTime)ADVANCED: Sets the query to execute as of the past time.voidsetBatchFetchPolicy(BatchFetchPolicy batchFetchPolicy)Set the batch fetch policy for configuring batch fetching.voidsetBatchFetchSize(int size)PUBLIC: Set the batch fetch size for the query.voidsetBatchFetchType(BatchFetchType type)PUBLIC: Set the batch fetch type for the query.voidsetBatchObjects(java.util.Map<java.lang.Object,java.lang.Object> batchObjects)INTERNAL: Set temporary map of batched objects.voidsetBatchReadAttributeExpressions(java.util.List<Expression> attributeExpressions)INTERNAL: Set all attributes specified for batch reading.voidsetCacheUsage(int cacheUsage)PUBLIC: Set the cache usage.voidsetDescriptor(ClassDescriptor descriptor)INTERNAL: Set the descriptor for the query.voidsetDistinctState(short distinctState)ADVANCED: If a distinct has been set the DISTINCT clause will be printed.voidsetEJBQLString(java.lang.String ejbqlString)PUBLIC: Set the EJBQL string of the query.voidsetExampleObject(java.lang.Object newExampleObject)PUBLIC: Set the example object of the query to be the newExampleObject.voidsetExpressionBuilder(ExpressionBuilder builder)INTERNAL Sets the default expression builder for this query.voidsetFetchGroup(FetchGroup newFetchGroup)Set a dynamic (use case) fetch group to the query.voidsetFetchGroupName(java.lang.String groupName)Set a descriptor-level pre-defined named fetch group to the query.voidsetInMemoryQueryIndirectionPolicy(InMemoryQueryIndirectionPolicy inMemoryQueryIndirectionPolicy)PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query.voidsetInMemoryQueryIndirectionPolicyState(int inMemoryQueryIndirectionPolicy)PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query.voidsetIsPrepared(boolean isPrepared)INTERNAL: Clear cached flags when un-preparing.protected voidsetIsPreparedKeepingSubclassData(boolean isPrepared)INTERNAL: Clear cached flags when un-preparing.voidsetIsPrePrepared(boolean isPrePrepared)INTERNAL: If changes are made to the query that affect the derived SQL or Call parameters the query needs to be prepared again.voidsetIsReadOnly(boolean isReadOnly)PUBLIC: Set the query to be read-only.voidsetIsResultSetAccessOptimizedQuery(boolean isResultSetAccessOptimizedQuery)ADVANCED: Set if the query should be optimized to build directly from the result set.voidsetIsResultSetOptimizedQuery(boolean isResultSetOptimizedQuery)ADVANCED: Set if the query should be optimized to build directly from the result set.voidsetJoinedAttributeExpressions(java.util.List expressions)INTERNAL: Convenience method for project mapping.voidsetJoinedAttributeManager(org.eclipse.persistence.internal.queries.JoinedAttributeManager joinedAttributeManager)INTERNAL: Set join manager responsible for managing all aspects of joining for the query.voidsetLoadGroup(LoadGroup loadGroup)Set a load group to the query.voidsetLockingClause(org.eclipse.persistence.internal.expressions.ForUpdateClause clause)INTERNAL: The locking clause contains a list of expressions representing which objects are to be locked by the query.voidsetLockMode(short lockMode)PUBLIC: Sets whether this is a pessimistically locking query.booleansetLockModeType(java.lang.String lockModeType, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Sets a javax.persistence.LockModeType to used with this queries execution.voidsetNonFetchJoinAttributeExpressions(java.util.List<Expression> nonFetchJoinExpressions)INTERNAL: Return the attributes that must be joined, but not fetched, that is, do not trigger the value holder.voidsetOrderByExpressions(java.util.List<Expression> orderByExpressions)INTERNAL: Set the order expressions for the query.voidsetPartialAttributeExpressions(java.util.List<Expression> partialAttributeExpressions)INTERNAL: Set the partial attributes to select.voidsetQueryByExamplePolicy(QueryByExamplePolicy queryByExamplePolicy)PUBLIC: The QueryByExamplePolicy, is a useful to customize the query when Query By Example is used.voidsetReferenceClass(java.lang.Class aClass)REQUIRED: Set the reference class for the query.voidsetReferenceClassName(java.lang.String aClass)INTERNAL: Set the reference class for the query.voidsetSelectionCriteria(Expression expression)PUBLIC: Set the Expression/where clause of the query.voidsetShouldExtendPessimisticLockScope(boolean isExtended)INTERNAL: Indicates whether pessimistic lock should also be applied to relation tables (ManyToMany and OneToOne mappings), reference tables (DirectCollection and AggregateCollection mapping).voidsetShouldFilterDuplicates(boolean shouldFilterDuplicates)PUBLIC: Set if duplicate rows should be filter when using 1-m joining.voidsetShouldIncludeData(boolean shouldIncludeData)INTERNAL: Set if the rows for the result of the query should also be returned using a complex query result.voidsetShouldOuterJoinSubclasses(boolean shouldOuterJoinSubclasses)PUBLIC: Set if an outer join should be used to read subclasses.voidsetShouldUseDefaultFetchGroup(boolean shouldUseDefaultFetchGroup)Set false if the user does not want to use the default fetch group defined in the descriptor level.voidsetShouldUseSerializedObjectPolicy(boolean shouldUseSerializedObjectPolicy)INTERNAL: Set a flag that indicates whether the query should use SerializedObjectPolicy if descriptor has it.voidsetUnionExpressions(java.util.List<Expression> unionExpressions)INTERNAL: Set any union expressions.voidsetWaitTimeout(java.lang.Integer waitTimeout)PUBLIC: Sets that this a pessimistic wait locking query.voidsetWaitTimeoutUnit(java.util.concurrent.TimeUnit waitTimeoutUnit)booleanshouldCheckCache()PUBLIC: Return if the cache should be checked.booleanshouldCheckCacheOnly()PUBLIC: Return if cache should be checked.booleanshouldCheckDescriptorForCacheUsage()PUBLIC: Return whether the descriptor's disableCacheHits setting should be checked prior to querying the cache.booleanshouldConformResultsInUnitOfWork()PUBLIC: Should the results will be checked against the changes within the unit of work and object no longer matching or deleted will be remove, matching new objects will also be added..booleanshouldDistinctBeUsed()INTERNAL: return true if this query should use a distinctbooleanshouldExtendPessimisticLockScope()INTERNAL: Indicates whether pessimistic lock should also be applied to relation tables (ManyToMany and OneToOne mappings), reference tables (DirectCollection and AggregateCollection mapping).booleanshouldFilterDuplicates()PUBLIC: Return if duplicate rows should be filter when using 1-m joining.booleanshouldIncludeData()INTERNAL: Return if the rows for the result of the query should also be returned using a complex query result.booleanshouldOuterJoinSubclasses()PUBLIC: Return if an outer join should be used to read subclasses.booleanshouldReadAllMappings()INTERNAL: Return if this is a full object query, not partial nor fetch group.booleanshouldReadMapping(DatabaseMapping mapping, FetchGroup fetchGroup)INTERNAL: Check if the mapping is part of the partial attributes.booleanshouldUseDefaultFetchGroup()Return false if the query does not use the default fetch group defined in the descriptor level.booleanshouldUseSerializedObjectPolicy()INTERNAL: Indicates whether the query should use SerializedObjectPolicy if descriptor has it.booleansupportsResultSetAccessOptimizationOnExecute()INTERNAL: Indicates whether the query can use ResultSet optimization.booleansupportsResultSetAccessOptimizationOnPrepare()INTERNAL: Indicates whether the query can use ResultSet optimization.java.lang.StringtoString()voidunion(ReportQuery query)PUBLIC: Union the query results with the other query.voiduseDistinct()ADVANCED: If a distinct has been set the DISTINCT clause will be printed.booleanusesResultSetAccessOptimization()INTERNAL: Return if the query uses ResultSet optimization.-
Methods inherited from class org.eclipse.persistence.queries.ObjectBuildingQuery
clonedQueryExecutionComplete, convertClassNamesToClasses, getDataResults, getExecutionTime, getLockMode, getPrefetchedCacheKeys, getQueryPrimaryKey, isAttributeJoined, isCacheCheckComplete, isObjectBuildingQuery, isRegisteringResults, postRegisterIndividualResult, prepareCustomQuery, printInnerJoinInWhereClause, registerIndividualResult, requiresDeferredLocks, setExecutionTime, setPrefetchedCacheKeys, setPrintInnerJoinInWhereClause, setRequiresDeferredLocks, setShouldBuildNullForNullPk, setShouldRefreshIdentityMapResult, setShouldRefreshRemoteIdentityMapResult, setShouldRegisterResultsInUnitOfWork, setShouldUseExclusiveConnection, setWasDefaultLockMode, shouldBuildNullForNullPk, shouldRefreshIdentityMapResult, shouldRefreshRemoteIdentityMapResult, shouldRegisterResultsInUnitOfWork, shouldUseExclusiveConnection, wasDefaultLockMode
-
Methods inherited from class org.eclipse.persistence.queries.ReadQuery
cacheQueryResults, cacheResult, clearQueryResults, doNotCacheQueryResults, getFetchSize, getFirstResult, getInternalMax, getMaxRows, getQueryId, getQueryResults, getQueryResults, getQueryResults, getQueryResultsCachePolicy, getTemporaryCachedQueryResults, 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, checkPrepare, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, extractRemoteResult, getAccessor, getAccessors, getArgumentParameterTypes, getArguments, getArgumentTypeNames, getArgumentTypes, getArgumentValues, 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, isPrepared, isReadAllQuery, isReadObjectQuery, isReportQuery, isResultSetMappingQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isUserDefinedSQLCall, isValueReadQuery, isWriteObjectQuery, maintainCache, prepareCall, prepareInternal, redirectQuery, remoteExecute, removeProperty, replaceValueHoldersIn, resetMonitorName, retrieveBypassCache, rowFromArguments, setAccessor, setAccessors, setAllowNativeSQLQuery, setArguments, setArgumentTypeNames, setArgumentTypes, setArgumentValues, setCall, setCascadePolicy, setDatasourceCall, setDoNotRedirect, setExecutionSession, setFlushOnExecute, setHintString, setIsCustomQueryUsed, setIsExecutionClone, setIsNativeConnectionRequired, setIsUserDefined, setIsUserDefinedSQLCall, setJPQLString, setName, setNullableArguments, setParameterDelimiter, setPartitioningPolicy, setProperties, setProperty, setQueryMechanism, setQueryTimeout, setQueryTimeoutUnit, setRedirector, 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
-
-
-
-
Field Detail
-
READ
public static final java.lang.String READ
Names of the possible lock mode types, JPA 1.0 and 2.0- See Also:
- Constant Field Values
-
WRITE
public static final java.lang.String WRITE
- See Also:
- Constant Field Values
-
NONE
public static final java.lang.String NONE
Names of the possible lock mode types, JPA 2.0 only- See Also:
- Constant Field Values
-
PESSIMISTIC_
public static final java.lang.String PESSIMISTIC_
- See Also:
- Constant Field Values
-
PESSIMISTIC_READ
public static final java.lang.String PESSIMISTIC_READ
- See Also:
- Constant Field Values
-
PESSIMISTIC_WRITE
public static final java.lang.String PESSIMISTIC_WRITE
- See Also:
- Constant Field Values
-
PESSIMISTIC_FORCE_INCREMENT
public static final java.lang.String PESSIMISTIC_FORCE_INCREMENT
- See Also:
- Constant Field Values
-
OPTIMISTIC
public static final java.lang.String OPTIMISTIC
- See Also:
- Constant Field Values
-
OPTIMISTIC_FORCE_INCREMENT
public static final java.lang.String OPTIMISTIC_FORCE_INCREMENT
- See Also:
- Constant Field Values
-
defaultBuilder
protected ExpressionBuilder defaultBuilder
Provide a default builder so that it's easier to be consistent
-
cacheUsage
protected int cacheUsage
Allow for the cache usage to be specified to enable in-memory querying.
-
UseDescriptorSetting
public static final int UseDescriptorSetting
- See Also:
- Constant Field Values
-
DoNotCheckCache
public static final int DoNotCheckCache
- See Also:
- Constant Field Values
-
CheckCacheByExactPrimaryKey
public static final int CheckCacheByExactPrimaryKey
- See Also:
- Constant Field Values
-
CheckCacheByPrimaryKey
public static final int CheckCacheByPrimaryKey
- See Also:
- Constant Field Values
-
CheckCacheThenDatabase
public static final int CheckCacheThenDatabase
- See Also:
- Constant Field Values
-
CheckCacheOnly
public static final int CheckCacheOnly
- See Also:
- Constant Field Values
-
ConformResultsInUnitOfWork
public static final int ConformResultsInUnitOfWork
- See Also:
- Constant Field Values
-
additionalFields
protected java.util.List<java.lang.Object> additionalFields
Allow for additional fields to be selected, used for m-m batch reading. Can contain DatabaseField or Expression.
-
shouldIncludeData
protected boolean shouldIncludeData
Allow for a complex result to be return including the rows and objects, used for m-m batch reading.
-
isPrePrepared
protected boolean isPrePrepared
Allow a prePrepare stage to build the expression for EJBQL and QBE and resolve joining.
-
distinctState
protected short distinctState
Indicates if distinct should be used or not.
-
UNCOMPUTED_DISTINCT
public static final short UNCOMPUTED_DISTINCT
- See Also:
- Constant Field Values
-
USE_DISTINCT
public static final short USE_DISTINCT
- See Also:
- Constant Field Values
-
DONT_USE_DISTINCT
public static final short DONT_USE_DISTINCT
- See Also:
- Constant Field Values
-
inMemoryQueryIndirectionPolicy
protected int inMemoryQueryIndirectionPolicy
Used to determine behavior of indirection in in-memory querying and conforming.
-
fetchGroup
protected FetchGroup fetchGroup
FetchGroupspecified on this query. When set this FetchGroup will override thefetchGroupNameand the use of the descriptor'sFetchGroupManager.getDefaultFetchGroup()
-
fetchGroupName
protected java.lang.String fetchGroupName
Name ofFetchGroupstored in theFetchGroupManagerof the reference class' descriptor or any of its parent descriptors.
-
shouldUseDefaultFetchGroup
protected boolean shouldUseDefaultFetchGroup
Flag to turn on/off the use of the default fetch group.
-
loadGroup
protected LoadGroup loadGroup
Specifies indirection that should be instantiated before returning result
-
nonFetchJoinAttributeExpressions
protected java.util.List<Expression> nonFetchJoinAttributeExpressions
Stores the non fetchjoin attributes, these are joins that will be represented in the where clause but not in the select.
-
partialAttributeExpressions
protected java.util.List<Expression> partialAttributeExpressions
Stores the partial attributes that have been added to this query
-
joinedAttributeManager
protected org.eclipse.persistence.internal.queries.JoinedAttributeManager joinedAttributeManager
Stores the helper object for dealing with joined attributes
-
batchFetchPolicy
protected BatchFetchPolicy batchFetchPolicy
Defines batch fetching configuration.
-
isReferenceClassLocked
protected java.lang.Boolean isReferenceClassLocked
PERF: Caches locking policy isReferenceClassLocked setting.
-
isResultSetOptimizedQuery
protected boolean isResultSetOptimizedQuery
PERF: Allow queries to build directly from the database result-set.
-
isResultSetAccessOptimizedQuery
protected java.lang.Boolean isResultSetAccessOptimizedQuery
PERF: Allow queries to build while accessing the database result-set. Skips accessing result set non-pk fields in case the cached object is found. If ResultSet optimization is used (isResultSetOptimizedQuery is set to true) then ResultSet Access optimization is ignored.
-
isResultSetAccessOptimizedQueryDefault
public static boolean isResultSetAccessOptimizedQueryDefault
If neither query specifies isResultSetOptimizedQuery nor session specifies shouldOptimizeResultSetAccess then this value is used to indicate whether optimization should be attempted
-
usesResultSetAccessOptimization
protected transient java.lang.Boolean usesResultSetAccessOptimization
PERF: Indicates whether the query is actually using ResultSet optimization. If isResultSetOptimizedQuery==null set automatically before executing call.
-
isReadOnly
protected boolean isReadOnly
PERF: Allow queries to be defined as read-only in unit of work execution.
-
shouldOuterJoinSubclasses
protected java.lang.Boolean shouldOuterJoinSubclasses
Define if an outer join should be used to read subclasses.
-
concreteSubclassCalls
protected java.util.Map<java.lang.Class,org.eclipse.persistence.internal.databaseaccess.DatabaseCall> concreteSubclassCalls
Allow concrete subclasses calls to be prepared and cached for inheritance queries.
-
concreteSubclassQueries
protected java.util.Map<java.lang.Class,DatabaseQuery> concreteSubclassQueries
Allow concrete subclasses queries to be prepared and cached for inheritance queries.
-
aggregateQueries
protected java.util.Map<DatabaseMapping,ObjectLevelReadQuery> aggregateQueries
Allow aggregate queries to be prepared and cached.
-
concreteSubclassJoinedMappingIndexes
protected java.util.Map<java.lang.Class,java.util.Map<DatabaseMapping,java.lang.Object>> concreteSubclassJoinedMappingIndexes
Allow concrete subclasses joined mapping indexes to be prepared and cached for inheritance queries.
-
lockModeType
protected java.lang.String lockModeType
Used when specifying a lock mode for the query
-
waitTimeout
protected java.lang.Integer waitTimeout
waitTimeout has three possible setting: null, 0 and 1..N null: use the session.getPessimisticLockTimeoutDefault() if available. 0: issue a LOCK_NOWAIT 1..N: use this value to set the WAIT clause.
-
waitTimeoutUnit
protected java.util.concurrent.TimeUnit waitTimeoutUnit
-
orderByExpressions
protected java.util.List<Expression> orderByExpressions
Used for ordering support.
-
shouldExtendPessimisticLockScope
protected boolean shouldExtendPessimisticLockScope
Indicates whether pessimistic lock should also be applied to relation tables (ManyToMany and OneToOne mappings), reference tables (DirectCollection and AggregateCollection mapping).
-
unionExpressions
protected java.util.List<Expression> unionExpressions
Allow a query's results to be unioned (UNION, INTERSECT, EXCEPT) with another query results.
-
isCachedExpressionQuery
protected boolean isCachedExpressionQuery
Indicates whether the query is cached as an expression query in descriptor's query manager.
-
shouldUseSerializedObjectPolicyDefault
public static boolean shouldUseSerializedObjectPolicyDefault
default value for shouldUseSerializedObjectPolicy
-
shouldUseSerializedObjectPolicy
protected boolean shouldUseSerializedObjectPolicy
Indicates whether the query should use SerializedObjectPolicy if descriptor has it.
-
-
Method Detail
-
union
public void union(ReportQuery query)
PUBLIC: Union the query results with the other query.
-
intersect
public void intersect(ReportQuery query)
PUBLIC: Intersect the query results with the other query.
-
except
public void except(ReportQuery query)
PUBLIC: Except the query results with the other query.
-
addUnionExpression
public void addUnionExpression(Expression union)
PUBLIC: Add the union expression to the query. A union expression must be created with the query's expression builder and one of union/unionAll/intersect/intersectAll/except/exceptAll with a subquery expression.
-
getUnionExpressions
public java.util.List<Expression> getUnionExpressions()
Return any union expressions.
-
setUnionExpressions
public void setUnionExpressions(java.util.List<Expression> unionExpressions)
INTERNAL: Set any union expressions.
-
addDescendingOrdering
public void addDescendingOrdering(java.lang.String queryKeyName)
PUBLIC: Order the query results by the object's attribute or query key name.
-
addOrdering
public void addOrdering(Expression orderingExpression)
PUBLIC: Add the ordering expression. This allows for ordering across relationships or functions. Example: readAllQuery.addOrdering(expBuilder.get("address").get("city").toUpperCase().descending())
-
equals
public boolean equals(java.lang.Object object)
INTERNAL: Return if the query is equal to the other. This is used to allow dynamic expression query SQL to be cached.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
INTERNAL: Compute a consistent hash-code for the expression. This is used to allow dynamic expression's SQL to be cached.- Overrides:
hashCodein classjava.lang.Object
-
isReadOnly
public boolean isReadOnly()
PUBLIC: Return if the query is read-only. This allows queries executed against a UnitOfWork to be read-only. This means the query will be executed against the Session, and the resulting objects will not be tracked for changes. The resulting objects are from the Session shared cache, and must not be modified.
-
setIsReadOnly
public void setIsReadOnly(boolean isReadOnly)
PUBLIC: Set the query to be read-only. This allows queries executed against a UnitOfWork to be read-only. This means the query will be executed against the Session, and the resulting objects will not be tracked for changes. The resulting objects are from the Session shared cache, and must not be modified.
-
setWaitTimeout
public void setWaitTimeout(java.lang.Integer waitTimeout)
PUBLIC: Sets that this a pessimistic wait locking query.- ObjectBuildingQuery.LOCK: SELECT .... FOR UPDATE WAIT issued.
Fine Grained Locking: On execution the reference class and those of all joined attributes will be checked. If any of these have a PessimisticLockingPolicy set on their descriptor, they will be locked in a SELECT ... FOR UPDATE OF ... {NO WAIT}. Issues fewer locks and avoids setting the lock mode on each query.
Example:
readAllQuery.setSelectionCriteria(employee.get("address").equal("Ottawa"));- LOCK: all employees in Ottawa and all referenced Ottawa addresses will be locked and the lock will wait only the specified amount of time.
- See Also:
PessimisticLockingPolicy
-
setWaitTimeoutUnit
public void setWaitTimeoutUnit(java.util.concurrent.TimeUnit waitTimeoutUnit)
-
checkCustomQueryFlag
protected abstract java.lang.Boolean checkCustomQueryFlag(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)INTERNAL: Check and return custom query flag. Custom query flag value is initialized when stored value isnull. Called fromcheckForCustomQuery(AbstractSession, AbstractRecord)to retrieve custom query flag.- Parameters:
session- Current session.translationRow- Database record.- Returns:
- Current custom query flag. Value shall never be
null.
-
getReadQuery
protected abstract ObjectLevelReadQuery getReadQuery()
INTERNAL: Get custom read query from query manager. Called fromcheckForCustomQuery(AbstractSession, AbstractRecord)to retrieve custom read query.- Returns:
- Custom read query from query manager.
-
checkForCustomQuery
protected DatabaseQuery checkForCustomQuery(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
INTERNAL: Check to see if a custom query should be used for this query. This is done before the query is copied and prepared/executed. Value ofnullmeans there is none.- Overrides:
checkForCustomQueryin classDatabaseQuery- Parameters:
session- Current session.translationRow- Database record.- Returns:
- Custom database query or
nullwhen custom database query is not set.
-
clone
public java.lang.Object clone()
INTERNAL: Creates and returns a copy of this query.- Overrides:
clonein classObjectBuildingQuery- Returns:
- A clone of this instance.
-
deepClone
public java.lang.Object deepClone()
INTERNAL: Clone the query, including its selection criteria.Normally selection criteria are not cloned here as they are cloned later on during prepare.
- Overrides:
deepClonein classObjectBuildingQuery
-
acquireLocks
public void acquireLocks()
PUBLIC: Set the query to lock, this will also turn refreshCache on.
-
acquireLocksWithoutWaiting
public void acquireLocksWithoutWaiting()
PUBLIC: Set the query to lock without waiting (blocking), this will also turn refreshCache on.
-
addAdditionalField
public void addAdditionalField(org.eclipse.persistence.internal.helper.DatabaseField field)
INTERNAL: Additional fields can be added to a query. This is used in m-m batch reading to bring back the key from the join table.
-
addAdditionalField
public void addAdditionalField(Expression fieldExpression)
INTERNAL: Additional fields can be added to a query. This is used in m-m batch reading to bring back the key from the join table.
-
addJoinedAttribute
public void addJoinedAttribute(java.lang.String attributeName)
PUBLIC: Specify the relationship attribute to be join fetched in this query. The query will join the object(s) being read with the attribute, this allows all of the data required for the object(s) to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read.Note: This cannot be used for objects where it is possible not to have a part, as these objects will be omitted from the result set, unless an outer join is used through passing and expression using "getAllowingNull". To join fetch collection relationships use the addJoinedAttribute(Expression) using "anyOf" to "anyOfAllowingNone".
Example: query.addJoinedAttribute("address")
-
addJoinedAttribute
public void addJoinedAttribute(Expression attributeExpression)
PUBLIC: Specify the attribute to be join fetched in this query. The query will join the object(s) being read with the specified attribute, this allows all of the data required for the object(s) to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read.Note: This cannot be used for objects where it is possible not to have a part, as these objects will be omitted from the result set, unless an outer join is used through passing and expression using "getAllowingNull".
Example: The following will fetch along with Employee(s) "Jones" all projects they participate in along with teamLeaders and their addresses, teamMembers and their phones. query.setSelectionCriteria(query.getExpressionBuilder().get("lastName").equal("Jones")); Expression projects = query.getExpressionBuilder().anyOf("projects"); query.addJoinedAttribute(projects); Expression teamLeader = projects.get("teamLeader"); query.addJoinedAttribute(teamLeader); Expression teamLeaderAddress = teamLeader.getAllowingNull("address"); query.addJoinedAttribute(teamLeaderAddress); Expression teamMembers = projects.anyOf("teamMembers"); query.addJoinedAttribute(teamMembers); Expression teamMembersPhones = teamMembers.anyOfAllowingNone("phoneNumbers"); query.addJoinedAttribute(teamMembersPhones); Note that: the order is essential: an expression should be added before any expression derived from it; the object is built once - it won't be rebuilt if it to be read again as a joined attribute: in the example the query won't get phones for "Jones" - even though they are among teamMembers (for whom phones are read).
-
addNonFetchJoinedAttribute
public void addNonFetchJoinedAttribute(java.lang.String attributeName)
PUBLIC: Specify the relationship attribute to be join in this query. This allows the query results to be filtered based on the relationship join. The query will join the object(s) being read with the attribute. The difference between this and a joined fetched attribute is that it does not select the joined data nor populate the joined attribute, it is only used to filter the query results.Example: query.addNonFetchJoinedAttribute("address")
- See Also:
addNonFetchJoinedAttribute(Expression)
-
addNonFetchJoinedAttribute
public void addNonFetchJoinedAttribute(Expression attributeExpression)
PUBLIC: Specify the relationship attribute to be join in this query. This allows the query results to be filtered based on the relationship join. The query will join the object(s) being read with the attribute. The difference between this and a joined fetched attribute is that it does not select the joined data nor populate the joined attribute, it is only used to filter the query results.Example: query.addNonFetchJoinedAttribute(query.getExpressionBuilder().get("teamLeader").get("address"))
- See Also:
addNonFetchJoinedAttribute(Expression)
-
addNonFetchJoin
public void addNonFetchJoin(Expression target)
PUBLIC: Specify the object expression to be joined in this query. This allows the query results to be filtered based on the join to the object. The object should define an on clause that defines the join condition. This allows for two non-related objects to be joined.Example: (select all employees that are a team leader)
ExpressionBuilder project = new ExpressionBuilder(Project.class); ExpressionBuilder employee = new ExpressionBuilder(Employee.class); ReadAllQuery query = new ReadAllQuery(Employee.class, employee); query.addJoin(project.on(project.get("teamLeader").equal(employee)))
-
addPartialAttribute
public void addPartialAttribute(java.lang.String attributeName)
Deprecated.since EclipseLink 2.1, partial attributes replaced by fetch groups.PUBLIC: Specify that only a subset of the class' attributes be selected in this query.This allows for the query to be optimized through selecting less data.
Partial objects will be returned from the query, where the unspecified attributes will be left
null. The primary key will always be selected to allow re-querying of the whole object.Note: Because the object is not fully initialized it cannot be cached, and cannot be edited.
Note: You cannot have 2 partial attributes of the same type. You also cannot add a partial attribute which is of the same type as the class being queried.
Example: query.addPartialAttribute("firstName")
-
addSelectionFieldsForJoinedExpression
protected void addSelectionFieldsForJoinedExpression(java.util.List fields, boolean isCustomSQL, Expression expression)INTERNAL: The method adds to the passed input vector the fields or expressions corresponding to the passed join expression.
-
setAsOfClause
public void setAsOfClause(AsOfClause pastTime)
ADVANCED: Sets the query to execute as of the past time. Both the query execution and result will conform to the database as it existed in the past.Equivalent to query.getSelectionCriteria().asOf(pastTime) called immediately before query execution.
An as of clause at the query level will override any clauses set at the expression level. Useful in cases where the selection criteria is not known in advance, such as for query by example or primary key (selection object), or where you do not need to cache the result (report query).
Ideally an as of clause at the session level is superior as query results can then be cached. You must set
setShouldMaintainCache(false)To query all joined/batched attributes as of the same time set this.
cascadeAllParts().- Throws:
QueryException- (at execution time) unlesssetShouldMaintainCache(false)is set. If some more recent data were in the cache, this would be returned instead, and both the cache and query result would become inconsistent.- See Also:
hasAsOfClause(),Session.acquireHistoricalSession(org.eclipse.persistence.history.AsOfClause),Expression.asOf(org.eclipse.persistence.history.AsOfClause)- Since:
- OracleAS TopLink 10g (10.0.3)
-
addPartialAttribute
public void addPartialAttribute(Expression attributeExpression)
Deprecated.since EclipseLink 2.1, partial attributes replaced by fetch groups.PUBLIC: Specify that only a subset of the class' attributes be selected in this query.This allows for the query to be optimized through selecting less data.
Partial objects will be returned from the query, where the unspecified attributes will be left
null. The primary key will always be selected to allow re-querying of the whole object.Note: Because the object is not fully initialized it cannot be cached, and cannot be edited.
Note: You cannot have 2 partial attributes of the same type. You also cannot add a partial attribute which is of the same type as the class being queried.
Example: query.addPartialAttribute(query.getExpressionBuilder().get("address").get("city"))
-
buildObject
public java.lang.Object buildObject(org.eclipse.persistence.internal.sessions.AbstractRecord row)
INTERNAL: Used to build the object, and register it if in the context of a unit of work.- Overrides:
buildObjectin classReadQuery
-
checkCacheOnly
public void checkCacheOnly()
PUBLIC: The cache will checked completely, if the object is not found null will be returned or an error if the query is too complex. Queries can be configured to use the cache at several levels. Other caching option are available.- See Also:
setCacheUsage(int)
-
checkDescriptor
public void checkDescriptor(org.eclipse.persistence.internal.sessions.AbstractSession session) throws QueryExceptionINTERNAL: Ensure that the descriptor has been set.- Overrides:
checkDescriptorin classDatabaseQuery- Parameters:
session- Current session.- Throws:
QueryException
-
checkEarlyReturnLocal
protected abstract java.lang.Object checkEarlyReturnLocal(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)INTERNAL: Contains the body of the check early return call, implemented by subclasses.
-
checkEarlyReturn
public java.lang.Object checkEarlyReturn(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)INTERNAL: Check to see if this query already knows the return value without performing any further work.- Overrides:
checkEarlyReturnin classDatabaseQuery
-
checkPrepare
public void checkPrepare(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow, boolean force)INTERNAL: Check to see if this query needs to be prepare and prepare it. The prepare is done on the original query to ensure that the work is not repeated.- Overrides:
checkPreparein classDatabaseQuery
-
checkPrePrepare
public void checkPrePrepare(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: ObjectLevelReadQueries now have an explicit pre-prepare stage, which is for checking for pessimistic locking, and computing any joined attributes declared on the descriptor.
-
changeDescriptor
public void changeDescriptor(org.eclipse.persistence.internal.sessions.AbstractSession theSession)
INTERNAL: The reference class has been changed, need to reset the descriptor. Null out the current descriptor and call checkDescriptor Added Feb 27, 2001 JED for EJBQL feature
-
conformIndividualResult
protected java.lang.Object conformIndividualResult(java.lang.Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, org.eclipse.persistence.internal.sessions.AbstractRecord arguments, Expression selectionCriteriaClone, java.util.Map alreadyReturned)INTERNAL: Conforms and registers an individual result. This instance could be one of the elements returned from a read all query, the result of a Read Object query, or an element read from a cursor.A result needs to be registered before it can be conformed, so registerIndividualResult is called here.
Conforming on a result from the database is lenient. Since the object matched the query on the database we assume it matches here unless we can determine for sure that it was changed in this UnitOfWork not to conform.
- Parameters:
clone- the clone to returnarguments- the parameters this query was executed withselectionCriteriaClone- the expression to conform to. If was a selection object or key, null (which all conform to) is usedalreadyReturned- a hashtable of objects already found by scanning the UnitOfWork cache for conforming instances. Prevents duplicates.unitOfWork- current UnitOfWork- Returns:
- a clone, or null if result does not conform.
-
conformResultsInUnitOfWork
public void conformResultsInUnitOfWork()
PUBLIC: The cache will checked completely, if the object is not found the database will be queried, and the database result will be verified with what is in the cache and/or unit of work including new objects. This can lead to poor performance so it is recommended that only the database be queried in most cases. Queries can be configured to use the cache at several levels. Other caching option are available.- See Also:
setCacheUsage(int)
-
dontAcquireLocks
public void dontAcquireLocks()
PUBLIC: Set the query not to lock.
-
dontCheckCache
public void dontCheckCache()
PUBLIC: This can be used to explicitly disable the cache hit. The cache hit may not be desired in some cases, such as stored procedures that accept the primary key but do not query on it.
-
dontRefreshIdentityMapResult
public void dontRefreshIdentityMapResult()
PUBLIC: When unset means perform read normally and dont do refresh.- Overrides:
dontRefreshIdentityMapResultin classObjectBuildingQuery
-
dontRefreshRemoteIdentityMapResult
public void dontRefreshRemoteIdentityMapResult()
PUBLIC: When unset means perform read normally and dont do refresh.- Overrides:
dontRefreshRemoteIdentityMapResultin classObjectBuildingQuery
-
dontUseDistinct
public void dontUseDistinct()
ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by EclipseLink for batch reading but may also be used directly for advanced queries or report queries.
-
prepareOutsideUnitOfWork
public DatabaseQuery prepareOutsideUnitOfWork(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: There is a very special case where a query may be a bean-level pessimistic locking query.If that is so, only queries executed inside of a UnitOfWork should have a locking clause. In the extremely rare case that we execute a locking query outside of a UnitOfWork, must disable locking so that we do not get a fetch out of sequence error.
-
execute
public java.lang.Object execute(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow) throws DatabaseException, OptimisticLockExceptionINTERNAL: Execute the query. If there are objects in the cache return the results of the cache lookup.- Overrides:
executein classDatabaseQuery- Parameters:
session- - the session in which the receiver will be executed.- Returns:
- An object, the result of executing the query.
- Throws:
DatabaseException- - an error has occurred on the database.OptimisticLockException- - an error has occurred using the optimistic lock feature.
-
executeDatabaseQuery
public java.lang.Object executeDatabaseQuery() throws DatabaseExceptionINTERNAL: 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.
-
executeObjectLevelReadQuery
protected abstract java.lang.Object executeObjectLevelReadQuery() throws DatabaseExceptionExecutes the prepared query on the datastore.- Throws:
DatabaseException
-
executeObjectLevelReadQueryFromResultSet
protected abstract java.lang.Object executeObjectLevelReadQueryFromResultSet() throws DatabaseExceptionExecutes the prepared query on the datastore.- Throws:
DatabaseException
-
executeInUnitOfWork
public java.lang.Object executeInUnitOfWork(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow) throws DatabaseException, OptimisticLockExceptionINTERNAL: Execute the query in the unit of work. This allows any pre-execute checks to be done for unit of work queries.- Overrides:
executeInUnitOfWorkin classDatabaseQuery- Parameters:
unitOfWork- - the session in which the receiver will be executed.translationRow- - the arguments- Returns:
- An object, the result of executing the query.
- Throws:
DatabaseException- - an error has occurred on the database.OptimisticLockException- - an error has occurred using the optimistic lock feature.
-
getAdditionalFields
public java.util.List<java.lang.Object> getAdditionalFields()
INTERNAL: Additional fields can be added to a query. This is used in m-m batch reading to bring back the key from the join table.
-
getAsOfClause
public AsOfClause getAsOfClause()
ADVANCED: Answers the past time this query is as of.- Returns:
- An immutable object representation of the past time.
nullif no clause set,AsOfClause.NO_CLAUSEif clause explicitly set tonull. - See Also:
AsOfClause,setAsOfClause(org.eclipse.persistence.history.AsOfClause),hasAsOfClause()
-
getCacheUsage
public int getCacheUsage()
PUBLIC: Return the cache usage. By default only primary key read object queries will first check the cache before accessing the database. Any query can be configure to query against the cache completely, by key or ignore the cache check.Valid values are:
- DoNotCheckCache
- CheckCacheByExactPrimaryKey
- CheckCacheByPrimaryKey
- CheckCacheThenDatabase
- CheckCacheOnly
- ConformResultsInUnitOfWork
- UseDescriptorSetting Note: UseDescriptorSetting functions like CheckCacheByPrimaryKey, except checks the appropriate descriptor's shouldDisableCacheHits setting when querying on the cache.
-
getDistinctState
public short getDistinctState()
ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by EclipseLink for batch reading but may also be used directly for advanced queries or report queries.
-
getExampleObject
public java.lang.Object getExampleObject()
PUBLIC: This method returns the current example object. The "example" object is an actual domain object, provided by the client, from which an expression is generated. This expression is used for a query of all objects from the same class, that match the attribute values of the "example" object.
-
getExpressionBuilder
public ExpressionBuilder getExpressionBuilder()
REQUIRED: Get the expression builder which should be used for this query. This expression builder should be used to build all expressions used by this query.
-
setExpressionBuilder
public void setExpressionBuilder(ExpressionBuilder builder)
INTERNAL Sets the default expression builder for this query.
-
getInMemoryQueryIndirectionPolicyState
public int getInMemoryQueryIndirectionPolicyState()
PUBLIC: Returns the InMemoryQueryIndirectionPolicy for this query
-
getInMemoryQueryIndirectionPolicy
public InMemoryQueryIndirectionPolicy getInMemoryQueryIndirectionPolicy()
PUBLIC: Returns the InMemoryQueryIndirectionPolicy for this query
-
getJoinedAttributeManager
public org.eclipse.persistence.internal.queries.JoinedAttributeManager getJoinedAttributeManager()
INTERNAL: Return join manager responsible for managing all aspects of joining for the query. Queries without joining should not have a joinedAttributeManager.
-
setJoinedAttributeManager
public void setJoinedAttributeManager(org.eclipse.persistence.internal.queries.JoinedAttributeManager joinedAttributeManager)
INTERNAL: Set join manager responsible for managing all aspects of joining for the query.
-
hasJoining
public boolean hasJoining()
INTERNAL: Return if any attributes are joined. To avoid the initialization of the JoinedAttributeManager this should be first checked before accessing.
-
getJoinedAttributeExpressions
public java.util.List getJoinedAttributeExpressions()
INTERNAL: Convenience method for project mapping.
-
setJoinedAttributeExpressions
public void setJoinedAttributeExpressions(java.util.List expressions)
INTERNAL: Convenience method for project mapping.
-
getOrderByExpressions
public java.util.List<Expression> getOrderByExpressions()
INTERNAL: Return the order expressions for the query.
-
setOrderByExpressions
public void setOrderByExpressions(java.util.List<Expression> orderByExpressions)
INTERNAL: Set the order expressions for the query.
-
hasOrderByExpressions
public boolean hasOrderByExpressions()
INTERNAL: The order bys are lazy initialized to conserve space.
-
hasUnionExpressions
public boolean hasUnionExpressions()
INTERNAL: The unions are lazy initialized to conserve space.
-
shouldFilterDuplicates
public boolean shouldFilterDuplicates()
PUBLIC: Return if duplicate rows should be filter when using 1-m joining.
-
setShouldFilterDuplicates
public void setShouldFilterDuplicates(boolean shouldFilterDuplicates)
PUBLIC: Set if duplicate rows should be filter when using 1-m joining.
-
getLockingClause
public org.eclipse.persistence.internal.expressions.ForUpdateClause getLockingClause()
INTERNAL: It is not exactly as simple as a query being either locking or not. Any combination of the reference class object and joined attributes may be locked.
-
getNonFetchJoinAttributeExpressions
public java.util.List<Expression> getNonFetchJoinAttributeExpressions()
INTERNAL: Return the attributes that must be joined, but not fetched, that is, do not trigger the value holder.
-
getPartialAttributeExpressions
public java.util.List<Expression> getPartialAttributeExpressions()
INTERNAL: Return the partial attributes to select.
-
getQueryByExamplePolicy
public QueryByExamplePolicy getQueryByExamplePolicy()
PUBLIC: When using Query By Example, an instance of QueryByExamplePolicy is used to customize the query. The policy is useful when special operations are to be used for comparisons (notEqual, lessThan, greaterThan, like etc.), when a certain value is to be ignored, or when dealing with nulls.
-
getReferenceClass
public java.lang.Class getReferenceClass()
PUBLIC: Return the reference class of the query.- Overrides:
getReferenceClassin classObjectBuildingQuery
-
getReferenceClassName
public java.lang.String getReferenceClassName()
INTERNAL: Return the reference class of the query.- Overrides:
getReferenceClassNamein classObjectBuildingQuery
-
hasAsOfClause
public boolean hasAsOfClause()
PUBLIC: Answers if the domain objects are to be read as of a past time.- See Also:
getAsOfClause()
-
hasNonFetchJoinedAttributeExpressions
public boolean hasNonFetchJoinedAttributeExpressions()
INTERNAL: Return the attributes that must be joined.
-
hasPartialAttributeExpressions
public boolean hasPartialAttributeExpressions()
INTERNAL: Return if partial attributes.- Overrides:
hasPartialAttributeExpressionsin classObjectBuildingQuery
-
hasAdditionalFields
public boolean hasAdditionalFields()
INTERNAL: Return if additional field.
-
getPartialAttributeSelectionFields
public java.util.Vector getPartialAttributeSelectionFields(boolean isCustomSQL)
INTERNAL: Return the fields required in the select clause, for patial attribute reading.
-
getFetchGroupNonNestedFieldsSet
public java.util.Set<org.eclipse.persistence.internal.helper.DatabaseField> getFetchGroupNonNestedFieldsSet()
INTERNAL: Return the set of fields required in the select clause, for fetch group reading.
-
getFetchGroupNonNestedFieldsSet
public java.util.Set<org.eclipse.persistence.internal.helper.DatabaseField> getFetchGroupNonNestedFieldsSet(DatabaseMapping nestedMapping)
INTERNAL: Return the set of fields required in the select clause, for fetch group reading.
-
getFetchGroupSelectionFields
public java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> getFetchGroupSelectionFields()
INTERNAL: Return the fields required in the select clause, for fetch group reading.
-
getFetchGroupSelectionFields
protected java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> getFetchGroupSelectionFields(DatabaseMapping nestedMapping)
INTERNAL: Return the fields required in the select clause, for fetch group reading. Top level (not nested) passes null instead of nestedMapping.
-
addJoinSelectionFields
public void addJoinSelectionFields(java.util.Vector fields, boolean isCustomSQL)INTERNAL: The method adds to the passed input vector the fields or expressions corresponding to the joins.
-
getSelectionFields
public java.util.Vector getSelectionFields()
INTERNAL: Return the fields selected by the query. This includes the partial or joined fields. This is only used for custom SQL executions.
-
getWaitTimeout
public java.lang.Integer getWaitTimeout()
PUBLIC: Return the WAIT timeout value of pessimistic locking query.
-
getWaitTimeoutUnit
public java.util.concurrent.TimeUnit getWaitTimeoutUnit()
-
initializeDefaultBuilder
protected void initializeDefaultBuilder()
Initialize the expression builder which should be used for this query. If there is a where clause, use its expression builder, otherwise generate one and cache it. This helps avoid unnecessary rebuilds.
-
isDistinctComputed
public boolean isDistinctComputed()
INTERNAL: return true if this query has computed its distinct value already
-
isLockQuery
public boolean isLockQuery()
PUBLIC: Answers if the query lock mode is known to be LOCK or LOCK_NOWAIT. In the case of DEFAULT_LOCK_MODE and the query reference class being a CMP entity bean, at execution time LOCK, LOCK_NOWAIT, or NO_LOCK will be decided.If a single joined attribute was configured for pessimistic locking then this will return true (after first execution) as the SQL contained a FOR UPDATE OF clause.
- Overrides:
isLockQueryin classObjectBuildingQuery
-
isLockQuery
public boolean isLockQuery(Session session)
ADVANCED: Answers if this query will issue any pessimistic locks.If the lock mode is not known (DEFAULT_LOCK_MODE / descriptor specified fine-grained locking) the lock mode will be determined now, to be either LOCK, LOCK_NOWAIT, or NO_LOCK.
- See Also:
isLockQuery()
-
isObjectLevelReadQuery
public boolean isObjectLevelReadQuery()
PUBLIC: Return if this is an object level read query.- Overrides:
isObjectLevelReadQueryin classDatabaseQuery
-
isPartialAttribute
public boolean isPartialAttribute(java.lang.String attributeName)
INTERNAL: Return if partial attribute.
-
shouldExtendPessimisticLockScope
public boolean shouldExtendPessimisticLockScope()
INTERNAL: Indicates whether pessimistic lock should also be applied to relation tables (ManyToMany and OneToOne mappings), reference tables (DirectCollection and AggregateCollection mapping).
-
isPrePrepared
protected boolean isPrePrepared()
PUBLIC: Queries prepare common stated in themselves.
-
setIsPrePrepared
public void setIsPrePrepared(boolean isPrePrepared)
INTERNAL: If changes are made to the query that affect the derived SQL or Call parameters the query needs to be prepared again.Automatically called internally.
The early phase of preparation is to check if this is a pessimistic locking query.
-
setShouldExtendPessimisticLockScope
public void setShouldExtendPessimisticLockScope(boolean isExtended)
INTERNAL: Indicates whether pessimistic lock should also be applied to relation tables (ManyToMany and OneToOne mappings), reference tables (DirectCollection and AggregateCollection mapping).
-
setIsPrepared
public void setIsPrepared(boolean isPrepared)
INTERNAL: Clear cached flags when un-preparing.- Overrides:
setIsPreparedin classDatabaseQuery
-
setIsPreparedKeepingSubclassData
protected void setIsPreparedKeepingSubclassData(boolean isPrepared)
INTERNAL: Clear cached flags when un-preparing. The method always keeps concrete subclass data (unlike setIsPrepared(false)).
-
prepare
protected void prepare() throws QueryExceptionINTERNAL: Prepare the receiver for execution in a session.- Overrides:
preparein classReadQuery- Throws:
QueryException
-
prepareFromCachedQuery
protected boolean prepareFromCachedQuery()
INTERNAL: Check if the query is cached and prepare from it. Return true if the query was cached.
-
copyFromQuery
public void copyFromQuery(DatabaseQuery query)
INTERNAL: Copy all setting from the query. This is used to morph queries from one type to the other. By default this calls prepareFromQuery, but additional properties may be required to be copied as prepareFromQuery only copies properties that affect the SQL.- Overrides:
copyFromQueryin classObjectBuildingQuery
-
prepareFromQuery
public void prepareFromQuery(DatabaseQuery query)
INTERNAL: Prepare the query from the prepared query. This allows a dynamic query to prepare itself directly from a prepared query instance. This is used in the EJBQL parse cache to allow preparsed queries to be used to prepare dynamic queries. This only copies over properties that are configured through EJBQL.- Overrides:
prepareFromQueryin classObjectBuildingQuery
-
prepareFetchGroup
public void prepareFetchGroup() throws QueryExceptionINTERNAL: Add mandatory attributes to fetch group, create entityFetchGroup.- Throws:
QueryException
-
prePrepare
protected void prePrepare() throws QueryExceptionINTERNAL: Prepare the receiver for execution in a session.- Throws:
QueryException
-
prepareQuery
protected void prepareQuery() throws QueryExceptionINTERNAL: Prepare the receiver for execution in a session.- Throws:
QueryException
-
prepareForRemoteExecution
protected void prepareForRemoteExecution() throws QueryExceptionINTERNAL: Prepare the receiver for execution in a session.- Overrides:
prepareForRemoteExecutionin classDatabaseQuery- Throws:
QueryException
-
refreshIdentityMapResult
public void refreshIdentityMapResult()
PUBLIC: Refresh the attributes of the object(s) resulting from the query. If cascading is used the private parts of the objects will also be refreshed.- Overrides:
refreshIdentityMapResultin classObjectBuildingQuery
-
refreshRemoteIdentityMapResult
public void refreshRemoteIdentityMapResult()
PUBLIC: Refresh the attributes of the object(s) resulting from the query. If cascading is used the private parts of the objects will also be refreshed.- Overrides:
refreshRemoteIdentityMapResultin classObjectBuildingQuery
-
registerResultInUnitOfWork
public abstract java.lang.Object registerResultInUnitOfWork(java.lang.Object result, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, org.eclipse.persistence.internal.sessions.AbstractRecord arguments, boolean buildDirectlyFromRows)INTERNAL: All objects queried via a UnitOfWork get registered here. If the query went to the database.Involves registering the query result individually and in totality, and hence refreshing / conforming is done here.
- Parameters:
result- may be collection (read all) or an object (read one), or even a cursor. If in transaction the shared cache will be bypassed, meaning the result may not be originals from the parent but raw database rows.unitOfWork- the unitOfWork the result is being registered in.arguments- the original arguments/parameters passed to the query execution. Used by conformingbuildDirectlyFromRows- If in transaction must construct a registered result from raw database rows.- Returns:
- the final (conformed, refreshed, wrapped) UnitOfWork query result
-
resetDistinct
public void resetDistinct()
ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by TopLink for batch reading but may also be used directly for advanced queries or report queries.
-
setAdditionalFields
public void setAdditionalFields(java.util.List<java.lang.Object> additionalFields)
INTERNAL: Additional fields can be added to a query. This is used in m-m batch reading to bring back the key from the join table.
-
shouldCheckCache
public boolean shouldCheckCache()
PUBLIC: Return if the cache should be checked.
-
setCacheUsage
public void setCacheUsage(int cacheUsage)
PUBLIC: Set the cache usage. By default only primary key read object queries will first check the cache before accessing the database. Any query can be configure to query against the cache completely, by key or ignore the cache check.Valid values are:
- DoNotCheckCache - The query does not check the cache but accesses the database, the cache will still be maintain.
- CheckCacheByExactPrimaryKey - If the query is exactly and only on the object's primary key the cache will be checked.
- CheckCacheByPrimaryKey - If the query contains the primary key and possible other values the cache will be checked.
- CheckCacheThenDatabase - The whole cache will be checked to see if there is any object matching the query, if not the database will be accessed.
- CheckCacheOnly - The whole cache will be checked to see if there is any object matching the query, if not null or an empty collection is returned.
- ConformResultsAgainstUnitOfWork - The results will be checked against the changes within the unit of work and object no longer matching or deleted will be remove, matching new objects will also be added.
- shouldCheckDescriptorForCacheUsage - This setting functions like CheckCacheByPrimaryKey, except checks the appropriate descriptor's shouldDisableCacheHits setting when querying on the cache.
-
setDescriptor
public void setDescriptor(ClassDescriptor descriptor)
INTERNAL: Set the descriptor for the query.- Overrides:
setDescriptorin classDatabaseQuery
-
setDistinctState
public void setDistinctState(short distinctState)
ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by TopLink for batch reading but may also be used directly for advanced queries or report queries.
-
setExampleObject
public void setExampleObject(java.lang.Object newExampleObject)
PUBLIC: Set the example object of the query to be the newExampleObject. The example object is used for Query By Example. When doing a Query By Example, an instance of the desired object is created, and the fields are filled with the values that are required in the result set. From these values the corresponding expression is built by EclipseLink, and the query is executed, returning the set of results.If a query already has a selection criteria this criteria and the generated query by example criteria will be conjuncted.
Once a query is executed you must make an explicit call to setExampleObject if the example object is changed, so the query will know to prepare itself again.
There is a caution to setting both a selection criteria and an example object: Only in this case if you set the example object again after execution you must then also reset the selection criteria. (This is because after execution the original criteria and Query By Example criteria were fused together, and the former cannot be easily recovered from the now invalid result).
Restrictions:
- Only attributes whose mappings are DirectToField, Aggregate (Embeddable), ObjectReference
(OneToOne) or Collection type OneToMany/ManyToMany are considered in a Query By Example object. The behaviour when an example object has attribute values for other mappings types is undefined.
- To ensure the example does not include any unsupported mappings the flag
QueryByExamplePolicy.setValidateExample(boolean)should be set to true on the corresponding QueryByExamplePolicy to ensure no unsupported relationship types are used in the example. - For OneToMany and ManyToMany mappings the elements within the collections and the references attribute values will be added to the expression as disjuncts (OR)
- To ensure the example does not include any unsupported mappings the flag
- Only attributes whose mappings are DirectToField, Aggregate (Embeddable), ObjectReference
(OneToOne) or Collection type OneToMany/ManyToMany are considered in a Query By Example object. The behaviour when an example object has attribute values for other mappings types is undefined.
-
setInMemoryQueryIndirectionPolicy
public void setInMemoryQueryIndirectionPolicy(InMemoryQueryIndirectionPolicy inMemoryQueryIndirectionPolicy)
PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query.
-
setInMemoryQueryIndirectionPolicyState
public void setInMemoryQueryIndirectionPolicyState(int inMemoryQueryIndirectionPolicy)
PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query.
-
setLockMode
public void setLockMode(short lockMode)
PUBLIC: Sets whether this is a pessimistically locking query.- ObjectBuildingQuery.LOCK: SELECT .... FOR UPDATE issued.
- ObjectBuildingQuery.LOCK_NOWAIT: SELECT .... FOR UPDATE NO WAIT issued.
- ObjectBuildingQuery.NO_LOCK: no pessimistic locking.
- ObjectBuildingQuery.DEFAULT_LOCK_MODE (default) and you have a CMP descriptor: fine grained locking will occur.
Fine Grained Locking: On execution the reference class and those of all joined attributes will be checked. If any of these have a PessimisticLockingPolicy set on their descriptor, they will be locked in a SELECT ... FOR UPDATE OF ... {NO WAIT}. Issues fewer locks and avoids setting the lock mode on each query.
Example:
readAllQuery.setSelectionCriteria(employee.get("address").equal("Ottawa"));- LOCK: all employees in Ottawa and all referenced Ottawa addresses will be locked.
- DEFAULT_LOCK_MODE: if address is a joined attribute, and only address has a pessimistic locking policy, only referenced Ottawa addresses will be locked.
- Overrides:
setLockModein classObjectBuildingQuery- See Also:
PessimisticLockingPolicy
-
getLockModeType
public java.lang.String getLockModeType()
INTERNAL: returns the javax.persistence.LockModeType string value set on this query.
-
setLockModeType
public boolean setLockModeType(java.lang.String lockModeType, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Sets a javax.persistence.LockModeType to used with this queries execution. The valid types are: - WRITE - READ - OPTIMISTIC - OPTIMISTIC_FORCE_INCREMENT - PESSIMISTIC_READ - PESSIMISTIC_WRITE - PESSIMISTIC_FORCE_INCREMENT - NONE Setting a null type will do nothing.- Returns:
- returns a failure flag indicating that we were UNABLE to set the lock mode because of validation. Callers to this method should check the return value and throw the necessary exception.
-
setNonFetchJoinAttributeExpressions
public void setNonFetchJoinAttributeExpressions(java.util.List<Expression> nonFetchJoinExpressions)
INTERNAL: Return the attributes that must be joined, but not fetched, that is, do not trigger the value holder.
-
setLockingClause
public void setLockingClause(org.eclipse.persistence.internal.expressions.ForUpdateClause clause)
INTERNAL: The locking clause contains a list of expressions representing which objects are to be locked by the query.Use for even finer grained control over what is and is not locked by a particular query.
-
setPartialAttributeExpressions
public void setPartialAttributeExpressions(java.util.List<Expression> partialAttributeExpressions)
INTERNAL: Set the partial attributes to select.
-
setEJBQLString
public void setEJBQLString(java.lang.String ejbqlString)
Description copied from class:DatabaseQueryPUBLIC: Set the EJBQL string of the query. If arguments are required in the string they will be preceded by "?" then the argument number.- Overrides:
setEJBQLStringin classDatabaseQuery
-
setQueryByExamplePolicy
public void setQueryByExamplePolicy(QueryByExamplePolicy queryByExamplePolicy)
PUBLIC: The QueryByExamplePolicy, is a useful to customize the query when Query By Example is used. The policy will control what attributes should, or should not be included in the query. When dealing with nulls, using special operations (notEqual, lessThan, like, etc.) for comparison, or choosing to include certain attributes at all times, it is useful to modify the policy accordingly.Once a query is executed you must make an explicit call to setQueryByExamplePolicy when changing the policy, so the query will know to prepare itself again.
There is a caution to setting both a selection criteria and an example object: If you set the policy after execution you must also reset the selection criteria. (This is because after execution the original criteria and Query By Example criteria are fused together, and the former cannot be easily recovered).
-
setReferenceClass
public void setReferenceClass(java.lang.Class aClass)
REQUIRED: Set the reference class for the query.- Overrides:
setReferenceClassin classObjectBuildingQuery
-
setReferenceClassName
public void setReferenceClassName(java.lang.String aClass)
INTERNAL: Set the reference class for the query.- Overrides:
setReferenceClassNamein classObjectBuildingQuery
-
setSelectionCriteria
public void setSelectionCriteria(Expression expression)
PUBLIC: Set the Expression/where clause of the query. The expression should be defined using the query's ExpressionBuilder.- Overrides:
setSelectionCriteriain classDatabaseQuery
-
setShouldIncludeData
public void setShouldIncludeData(boolean shouldIncludeData)
INTERNAL: Set if the rows for the result of the query should also be returned using a complex query result.- See Also:
ComplexQueryResult
-
shouldCheckCacheOnly
public boolean shouldCheckCacheOnly()
PUBLIC: Return if cache should be checked.
-
shouldCheckDescriptorForCacheUsage
public boolean shouldCheckDescriptorForCacheUsage()
PUBLIC: Return whether the descriptor's disableCacheHits setting should be checked prior to querying the cache.
-
shouldConformResultsInUnitOfWork
public boolean shouldConformResultsInUnitOfWork()
PUBLIC: Should the results will be checked against the changes within the unit of work and object no longer matching or deleted will be remove, matching new objects will also be added..
-
shouldDistinctBeUsed
public boolean shouldDistinctBeUsed()
INTERNAL: return true if this query should use a distinct
-
shouldIncludeData
public boolean shouldIncludeData()
INTERNAL: Return if the rows for the result of the query should also be returned using a complex query result.- See Also:
ComplexQueryResult
-
shouldOuterJoinSubclasses
public boolean shouldOuterJoinSubclasses()
PUBLIC: Return if an outer join should be used to read subclasses. By default a separate query is done for each subclass when querying for a root or branch inheritance class that has subclasses that span multiple tables.
-
setShouldOuterJoinSubclasses
public void setShouldOuterJoinSubclasses(boolean shouldOuterJoinSubclasses)
PUBLIC: Set if an outer join should be used to read subclasses. By default a separate query is done for each subclass when querying for a root or branch inheritance class that has subclasses that span multiple tables.
-
shouldReadAllMappings
public boolean shouldReadAllMappings()
INTERNAL: Return if this is a full object query, not partial nor fetch group.- Overrides:
shouldReadAllMappingsin classObjectBuildingQuery
-
shouldReadMapping
public boolean shouldReadMapping(DatabaseMapping mapping, FetchGroup fetchGroup)
INTERNAL: Check if the mapping is part of the partial attributes.- Overrides:
shouldReadMappingin classObjectBuildingQuery
-
useDistinct
public void useDistinct()
ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by EclipseLink for batch reading but may also be used directly for advanced queries or report queries.
-
isCachedExpressionQuery
public boolean isCachedExpressionQuery()
INTERNAL: Indicates whether the query is cached as an expression query in descriptor's query manager.
-
isClonePessimisticLocked
public boolean isClonePessimisticLocked(java.lang.Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)INTERNAL: Helper method that checks if clone has been locked with uow.- Overrides:
isClonePessimisticLockedin classObjectBuildingQuery
-
isReferenceClassLocked
protected boolean isReferenceClassLocked()
INTERNAL: Cache the locking policy isReferenceClassLocked check.
-
recordCloneForPessimisticLocking
public void recordCloneForPessimisticLocking(java.lang.Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)INTERNAL: Helper method that records clone with uow if query is pessimistic locking.- Overrides:
recordCloneForPessimisticLockingin classObjectBuildingQuery
-
isResultSetOptimizedQuery
public boolean isResultSetOptimizedQuery()
ADVANCED: Return if the query should be optimized to build directly from the result set. This optimization follows an optimized path and can only be used for, singleton primary key, direct mapped, simple type, no inheritance, uow isolated objects.
-
isResultSetAccessOptimizedQuery
public java.lang.Boolean isResultSetAccessOptimizedQuery()
ADVANCED: Return if the query result set access should be optimized.
-
usesResultSetAccessOptimization
public boolean usesResultSetAccessOptimization()
INTERNAL: Return if the query uses ResultSet optimization. Note that to be accurate it's required to be set by prepareResultSetAccessOptimization or checkResultSetAccessOptimization method. It's always returns the same value as this.isResultSetOptimizedQuery.booleanValue (if not null). Note that in this case if optimization is incompatible with other query settings then exception is thrown. Otherwise - if the session demand optimization and it is possible - optimizes (returns true), otherwise false.- Overrides:
usesResultSetAccessOptimizationin classObjectBuildingQuery
-
prepareResultSetAccessOptimization
protected void prepareResultSetAccessOptimization()
INTERNAL: Sets usesResultSetAccessOptimization based on isResultSetAccessOptimizedQuery, session default and query settings that could not be altered without re-preparing the query. Called when the query is prepared or in case usesResultSetAccessOptimization hasn't been set yet. Throws exception if isResultSetAccessOptimizedQuery==true cannot be accommodated because of a conflict with the query settings. In case of isResultSetAccessOptimizedQuery hasn't been set and session default conflicting with the the query settings the optimization is turned off.
-
clearUsesResultSetAccessOptimization
public void clearUsesResultSetAccessOptimization()
INTERNAL:
-
setIsResultSetOptimizedQuery
public void setIsResultSetOptimizedQuery(boolean isResultSetOptimizedQuery)
ADVANCED: Set if the query should be optimized to build directly from the result set. This optimization follows an optimized path and can only be used for, singleton primary key, direct mapped, simple type, no inheritance, uow isolated objects.
-
setIsResultSetAccessOptimizedQuery
public void setIsResultSetAccessOptimizedQuery(boolean isResultSetAccessOptimizedQuery)
ADVANCED: Set if the query should be optimized to build directly from the result set.
-
clearIsResultSetOptimizedQuery
public void clearIsResultSetOptimizedQuery()
ADVANCED: Clear the flag set by setIsResultSetOptimizedQuery method, allow to use default set on the session instead.
-
isDefaultLock
public boolean isDefaultLock()
INTERNAL: Helper method to determine the default mode. If true and query has a pessimistic locking policy, locking will be configured according to the pessimistic locking policy.- Overrides:
isDefaultLockin classObjectBuildingQuery
-
isDefaultPropertiesQuery
public boolean isDefaultPropertiesQuery()
INTERNAL: Return true if the query uses default properties. This is used to determine if this query is cacheable. i.e. does not use any properties that may conflict with another query with the same JPQL or selection criteria.- Overrides:
isDefaultPropertiesQueryin classReadQuery
-
hasDefaultBuilder
public boolean hasDefaultBuilder()
INTERNAL: Checks to see if a builder has been set on the query.
-
hasFetchGroup
public boolean hasFetchGroup()
Return if a fetch group is set in the query.
-
getFetchGroup
public FetchGroup getFetchGroup()
Return the fetch group set in the query. If a fetch group is not explicitly set in the query, default fetch group optionally defined in the descriptor would be used, unless the user explicitly calls query.setShouldUseDefaultFetchGroup(false). Note that the returned fetchGroup may be updated during preProcess.
-
getLoadGroup
public LoadGroup getLoadGroup()
Return the load group set in the query.- Overrides:
getLoadGroupin classObjectBuildingQuery
-
getExecutionFetchGroup
public FetchGroup getExecutionFetchGroup()
INTERNAL: Returns FetchGroup that will be applied to the query. Note that the returned fetchGroup may be updated during preProcess.- Overrides:
getExecutionFetchGroupin classObjectBuildingQuery
-
getExecutionFetchGroup
public FetchGroup getExecutionFetchGroup(ClassDescriptor descriptor)
INTERNAL: Returns FetchGroup that will be applied to the query. Note that the returned fetchGroup may be updated during preProcess.- Overrides:
getExecutionFetchGroupin classObjectBuildingQuery
-
hasExecutionFetchGroup
public boolean hasExecutionFetchGroup()
INTERNAL: Indicates whether a FetchGroup will be applied to the query.- Overrides:
hasExecutionFetchGroupin classObjectBuildingQuery
-
setFetchGroup
public void setFetchGroup(FetchGroup newFetchGroup)
Set a dynamic (use case) fetch group to the query.
-
setFetchGroupName
public void setFetchGroupName(java.lang.String groupName)
Set a descriptor-level pre-defined named fetch group to the query.
-
setLoadGroup
public void setLoadGroup(LoadGroup loadGroup)
Set a load group to the query.
-
getFetchGroupName
public java.lang.String getFetchGroupName()
Return the fetch group name set in the query.
-
shouldUseDefaultFetchGroup
public boolean shouldUseDefaultFetchGroup()
Return false if the query does not use the default fetch group defined in the descriptor level.
-
setShouldUseDefaultFetchGroup
public void setShouldUseDefaultFetchGroup(boolean shouldUseDefaultFetchGroup)
Set false if the user does not want to use the default fetch group defined in the descriptor level.
-
getConcreteSubclassCalls
public java.util.Map<java.lang.Class,org.eclipse.persistence.internal.databaseaccess.DatabaseCall> getConcreteSubclassCalls()
INTERNAL: Return the cache of concrete subclass calls. This allow concrete subclasses calls to be prepared and cached for inheritance queries.
-
getConcreteSubclassQueries
public java.util.Map<java.lang.Class,DatabaseQuery> getConcreteSubclassQueries()
INTERNAL: Return the cache of concrete subclass queries. This allow concrete subclasses calls to be prepared and cached for table per class inheritance and interface queries.
-
getAggregateQueries
public java.util.Map<DatabaseMapping,ObjectLevelReadQuery> getAggregateQueries()
INTERNAL: Return the cache of aggregate queries. This allows aggregate query clones to be cached.
-
getAggregateQuery
public ObjectLevelReadQuery getAggregateQuery(DatabaseMapping mapping)
INTERNAL: Return the aggregate query clone for the mapping.
-
setAggregateQuery
public void setAggregateQuery(DatabaseMapping mapping, ObjectLevelReadQuery query)
INTERNAL: Set the aggregate query clone for the mapping.
-
getConcreteSubclassJoinedMappingIndexes
public java.util.Map<java.lang.Class,java.util.Map<DatabaseMapping,java.lang.Object>> getConcreteSubclassJoinedMappingIndexes()
INTERNAL: Return the cache of concrete subclass joined mapping indexes. This allow concrete subclasses calls to be prepared and cached for inheritance queries.
-
isPrimaryKeyQuery
public boolean isPrimaryKeyQuery()
INTERNAL: Return if the query is known to be by primary key.
-
extendPessimisticLockScope
public void extendPessimisticLockScope()
INTERNAL: Extends pessimistic lock scope.
-
getBatchFetchPolicy
public BatchFetchPolicy getBatchFetchPolicy()
Return the batch fetch policy for configuring batch fetching.
-
setBatchFetchPolicy
public void setBatchFetchPolicy(BatchFetchPolicy batchFetchPolicy)
Set the batch fetch policy for configuring batch fetching.
-
getBatchReadAttributeExpressions
public java.util.List<Expression> getBatchReadAttributeExpressions()
INTERNAL: Return all attributes specified for batch reading.
-
setBatchReadAttributeExpressions
public void setBatchReadAttributeExpressions(java.util.List<Expression> attributeExpressions)
INTERNAL: Set all attributes specified for batch reading.
-
hasBatchReadAttributes
public boolean hasBatchReadAttributes()
INTERNAL: Return true is this query has batching
-
isAttributeBatchRead
public boolean isAttributeBatchRead(ClassDescriptor mappingDescriptor, java.lang.String attributeName)
INTERNAL: Return if the attribute is specified for batch reading.
-
computeBatchReadMappingQueries
public void computeBatchReadMappingQueries()
INTERNAL: Used to optimize joining by pre-computing the nested join queries for the mappings.
-
computeBatchReadAttributes
public void computeBatchReadAttributes()
INTERNAL: Compute the cache batched attributes. Used to recompute batched attributes for nested aggregate queries.
-
computeNestedQueriesForBatchReadExpressions
protected void computeNestedQueriesForBatchReadExpressions(java.util.List<Expression> batchReadExpressions)
INTERNAL: This method is used when computing the nested queries for batch read mappings. It recurses computing the nested mapping queries.
-
addBatchReadAttribute
public void addBatchReadAttribute(java.lang.String attributeName)
PUBLIC: Specify the foreign-reference mapped attribute to be optimized in this query. The query will execute normally, however when any of the batched parts is accessed, the parts will all be read in a single query, this allows all of the data required for the parts to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read. This can be used for one-to-one, one-to-many, many-to-many and direct collection mappings. The use of the expression allows for nested batch reading to be expressed.Example: query.addBatchReadAttribute("phoneNumbers")
-
addBatchReadAttribute
public void addBatchReadAttribute(Expression attributeExpression)
PUBLIC: Specify the foreign-reference mapped attribute to be optimized in this query. The query will execute normally, however when any of the batched parts is accessed, the parts will all be read in a single query, this allows all of the data required for the parts to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read. This can be used for one-to-one, one-to-many, many-to-many and direct collection mappings. The use of the expression allows for nested batch reading to be expressed.Example: query.addBatchReadAttribute(query.getExpressionBuilder().get("policies").get("claims"))
-
setBatchFetchType
public void setBatchFetchType(BatchFetchType type)
PUBLIC: Set the batch fetch type for the query. This can be JOIN, EXISTS, or IN. This defines the type of batch reading to use with the query. The query must have defined batch read attributes to set its fetch type.- See Also:
addBatchReadAttribute(Expression)
-
setBatchFetchSize
public void setBatchFetchSize(int size)
PUBLIC: Set the batch fetch size for the query. This is only relevant for the IN batch fetch type. This defines the max number of keys for the IN clause.
-
getBatchObjects
public java.util.Map<java.lang.Object,java.lang.Object> getBatchObjects()
INTERNAL: Return temporary map of batched objects.- Overrides:
getBatchObjectsin classDatabaseQuery
-
setBatchObjects
public void setBatchObjects(java.util.Map<java.lang.Object,java.lang.Object> batchObjects)
INTERNAL: Set temporary map of batched objects.- Overrides:
setBatchObjectsin classDatabaseQuery
-
toString
public java.lang.String toString()
- Overrides:
toStringin classDatabaseQuery
-
supportsResultSetAccessOptimizationOnPrepare
public boolean supportsResultSetAccessOptimizationOnPrepare()
INTERNAL: Indicates whether the query can use ResultSet optimization. The method is called when the query is prepared, so it should refer only to the attributes that cannot be altered without re-preparing the query. If the query is a clone and the original has been already prepared this method will be called to set a (transient and therefore set to null) usesResultSetAccessOptimization attribute.
-
supportsResultSetAccessOptimizationOnExecute
public boolean supportsResultSetAccessOptimizationOnExecute()
INTERNAL: Indicates whether the query can use ResultSet optimization. Note that the session must be already set. The method is called when the query is executed, so it should refer only to the attributes that can be altered without re-preparing the query.
-
shouldUseSerializedObjectPolicy
public boolean shouldUseSerializedObjectPolicy()
INTERNAL: Indicates whether the query should use SerializedObjectPolicy if descriptor has it.- Overrides:
shouldUseSerializedObjectPolicyin classObjectBuildingQuery
-
setShouldUseSerializedObjectPolicy
public void setShouldUseSerializedObjectPolicy(boolean shouldUseSerializedObjectPolicy)
INTERNAL: Set a flag that indicates whether the query should use SerializedObjectPolicy if descriptor has it.
-
-