- All Implemented Interfaces:
Serializable
,Cloneable
Purpose: Query used to delete a collection of objects. This is used by mappings to delete all of their target objects in a single database call. The SQL/SQLStatements must be provided.
DeleteAll can also be used with an Expression (or JPQL) to dynamically delete a set of objects from the database, and invalidate them in the cache.
Responsibilities:
- Stores & retrieves the objects to delete.
- Store the where clause used for the deletion.
- Since:
- TOPLink/Java 1.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.persistence.queries.DatabaseQuery
DatabaseQuery.ParameterType
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Defines if objects should be remove from the persistence context only (no database).List containing objects to be deleted, these should be removed from the identity map after deletion.Fields inherited from class org.eclipse.persistence.queries.ModifyAllQuery
defaultBuilder, INVALIDATE_CACHE, isPreparedUsingTempStorage, NO_CACHE, referenceClass, referenceClassName, result
Fields inherited from class org.eclipse.persistence.queries.ModifyQuery
forceBatchStatementExecution, isBatchExecutionSupported, modifyRow
Fields inherited from class org.eclipse.persistence.queries.DatabaseQuery
accessors, allowNativeSQLQuery, argumentFields, argumentParameterTypes, arguments, argumentTypeNames, argumentTypes, argumentValues, BATCH_FETCH_PROPERTY, CascadeAggregateDelete, CascadeAllParts, CascadeByMapping, CascadeDependentParts, cascadePolicy, CascadePrivateParts, descriptor, descriptors, doNotRedirect, executionSession, flushOnExecute, hintString, isCustomQueryUsed, isExecutionClone, isNativeConnectionRequired, isPrepared, isUserDefined, isUserDefinedSQLCall, monitorName, name, NoCascading, nullableArguments, parameterDelimiter, partitioningPolicy, properties, queryMechanism, queryTimeout, queryTimeoutUnit, redirector, session, sessionName, shouldBindAllParameters, shouldCacheStatement, shouldCloneCall, shouldMaintainCache, shouldPrepare, shouldRetrieveBypassCache, shouldReturnGeneratedKeys, shouldStoreBypassCache, shouldUseWrapperPolicy, shouldValidateUpdateCallCacheUse, sourceMapping, translationRow
-
Constructor Summary
ConstructorDescriptionPUBLIC:DeleteAllQuery
(Class<?> referenceClass) PUBLIC: Create a new delete all query for the class specified.DeleteAllQuery
(Class<?> referenceClass, Expression selectionCriteria) PUBLIC: Create a new delete all query for the class and the selection criteria specified. -
Method Summary
Modifier and TypeMethodDescriptionINTERNAL: Perform the work to delete a collection of objects.void
executeDeleteAll
(AbstractSession session, AbstractRecord translationRow, Vector objects) INTERNAL: Delete all queries are executed specially to avoid cloning and ensure preparing.executeInUnitOfWork
(UnitOfWorkImpl unitOfWork, AbstractRecord translationRow) INTERNAL: This method has to be broken.protected QueryRedirector
INTERNAL: Returns the specific default redirector for this query type.PUBLIC: Return the objects that are to be deletedboolean
PUBLIC: Return if this is a delete all query.boolean
INTERNAL: Return if objects should be remove from the persistence context only (no database).protected void
prepare()
INTERNAL: Prepare the receiver for execution in a session.void
setIsInMemoryOnly
(boolean isInMemoryOnly) INTERNAL: Set if objects should be remove from the persistence context only (no database).void
setObjects
(List<Object> objectCollection) PUBLIC (REQUIRED): Set the objects to be deleted.Methods inherited from class org.eclipse.persistence.queries.ModifyAllQuery
clonedQueryExecutionComplete, getCacheUsage, getExpressionBuilder, getReferenceClass, getReferenceClassName, initializeDefaultBuilder, initializeQuerySpecificDefaultBuilder, invalidateCache, isModifyAllQuery, isPreparedUsingTempStorage, mergeChangesIntoSharedCache, setCacheUsage, setExpressionBuilder, setIsPreparedUsingTempStorage, setReferenceClass, setReferenceClassName, setShouldDeferExecutionInUOW, shouldDeferExecutionInUOW, shouldInvalidateCache
Methods inherited from class org.eclipse.persistence.queries.ModifyQuery
forceBatchStatementExecution, getModifyRow, isBatchExecutionSupported, isModifyQuery, setForceBatchStatementExecution, setIsBatchExecutionSupported, setModifyRow
Methods inherited from class org.eclipse.persistence.queries.DatabaseQuery
addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgumentByTypeName, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, buildArgumentFields, buildSelectionCriteria, cacheStatement, cascadeAllParts, cascadeByMapping, cascadeOnlyDependentParts, cascadePrivateParts, checkDescriptor, checkEarlyReturn, checkForCustomQuery, checkPrepare, checkPrepare, clone, convertClassNamesToClasses, copyFromQuery, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, execute, extractRemoteResult, getAccessor, getAccessors, getArgumentParameterTypes, getArguments, getArgumentTypeNames, getArgumentTypes, getArgumentValues, getBatchObjects, getCall, getCascadePolicy, getDatasourceCall, getDatasourceCalls, 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, isDefaultPropertiesQuery, isDeleteObjectQuery, isDirectReadQuery, isExecutionClone, isExpressionQuery, isInsertObjectQuery, isJPQLCallQuery, isNativeConnectionRequired, isObjectBuildingQuery, isObjectLevelModifyQuery, isObjectLevelReadQuery, isPrepared, isReadAllQuery, isReadObjectQuery, isReadQuery, isReportQuery, isResultSetMappingQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isUserDefinedSQLCall, isValueReadQuery, isWriteObjectQuery, maintainCache, prepareCall, prepareCustomQuery, prepareForExecution, prepareForRemoteExecution, prepareFromQuery, prepareInternal, redirectQuery, remoteExecute, remoteExecute, removeProperty, replaceValueHoldersIn, resetMonitorName, retrieveBypassCache, rowFromArguments, setAccessor, setAccessors, setAllowNativeSQLQuery, setArguments, setArgumentTypeNames, setArgumentTypes, setArgumentValues, setBatchObjects, setCall, setCascadePolicy, setDatasourceCall, setDescriptor, setDoNotRedirect, setEJBQLString, setExecutionSession, setFlushOnExecute, setHintString, setIsCustomQueryUsed, setIsExecutionClone, setIsNativeConnectionRequired, setIsPrepared, setIsUserDefined, setIsUserDefinedSQLCall, setJPQLString, setName, setNullableArguments, setParameterDelimiter, setPartitioningPolicy, setProperties, setProperty, setQueryMechanism, setQueryTimeout, setQueryTimeoutUnit, setRedirector, setSelectionCriteria, setSession, setSessionName, setShouldBindAllParameters, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldRetrieveBypassCache, setShouldReturnGeneratedKeys, setShouldStoreBypassCache, setShouldUseWrapperPolicy, setShouldValidateUpdateCallCacheUse, setSourceMapping, setSQLStatement, setSQLString, setTranslationRow, shouldAllowNativeSQLQuery, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeByMapping, shouldCascadeOnlyDependentParts, shouldCascadeParts, shouldCascadePrivateParts, shouldCloneCall, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldPrepare, shouldRetrieveBypassCache, shouldReturnGeneratedKeys, shouldStoreBypassCache, shouldUseWrapperPolicy, shouldValidateUpdateCallCacheUse, storeBypassCache, toString
-
Field Details
-
objects
List containing objects to be deleted, these should be removed from the identity map after deletion. -
isInMemoryOnly
protected boolean isInMemoryOnlyDefines if objects should be remove from the persistence context only (no database). This is used if delete was already cascaded by the database.
-
-
Constructor Details
-
DeleteAllQuery
public DeleteAllQuery()PUBLIC: -
DeleteAllQuery
PUBLIC: Create a new delete all query for the class specified. -
DeleteAllQuery
PUBLIC: Create a new delete all query for the class and the selection criteria specified.
-
-
Method Details
-
isInMemoryOnly
public boolean isInMemoryOnly()INTERNAL: Return if objects should be remove from the persistence context only (no database). This is used if delete was already cascaded by the database. -
setIsInMemoryOnly
public void setIsInMemoryOnly(boolean isInMemoryOnly) INTERNAL: Set if objects should be remove from the persistence context only (no database). This is used if delete was already cascaded by the database. -
isDeleteAllQuery
public boolean isDeleteAllQuery()PUBLIC: Return if this is a delete all query.- Overrides:
isDeleteAllQuery
in classDatabaseQuery
-
executeInUnitOfWork
public Object executeInUnitOfWork(UnitOfWorkImpl unitOfWork, AbstractRecord translationRow) throws DatabaseException INTERNAL: This method has to be broken. If commit manager is not active either an exception should be thrown (ObjectLevelModify case), or a transaction should be started early and execute on parent if remote (dataModify case). A modify query is NEVER executed on the parent, unless remote session.- Overrides:
executeInUnitOfWork
in classModifyAllQuery
- 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.
-
executeDatabaseQuery
INTERNAL: Perform the work to delete a collection of objects. This skips the optimistic lock check and should not called for objects using locking.- Specified by:
executeDatabaseQuery
in classDatabaseQuery
- Returns:
- Integer the number of objects (rows) deleted.
- Throws:
DatabaseException
- - an error has occurred on the database.
-
executeDeleteAll
public void executeDeleteAll(AbstractSession session, AbstractRecord translationRow, Vector objects) throws DatabaseException INTERNAL: Delete all queries are executed specially to avoid cloning and ensure preparing.- Throws:
DatabaseException
-
getDefaultRedirector
INTERNAL: Returns the specific default redirector for this query type. There are numerous default query redirectors. See ClassDescriptor for their types.- Overrides:
getDefaultRedirector
in classDatabaseQuery
-
getObjects
PUBLIC: Return the objects that are to be deleted -
prepare
INTERNAL: Prepare the receiver for execution in a session.- Overrides:
prepare
in classDatabaseQuery
- Throws:
QueryException
-
setObjects
PUBLIC (REQUIRED): Set the objects to be deleted. Also REQUIRED is a selection criteria or SQL string that performs the deletion of the objects. This does not generate the SQL call from the deleted objects.List objects used as an indicator of one of two possible ways the query may behave:
objects != null - the "old" functionality used by OneToMany mapping objects deleted from the cache, either selection expression or custom sql should be provided for deletion from db;
objects == null - the "new" functionality (on par with UpdateAllQuery) the cache is either left alone or in-memory query finds the cached objects to be deleted, and these objects are invalidated in cache.
Note that empty objects is still objects != case. Signal that no cache altering is required. Used by AggregationCollectionMapping and OneToManyMapping in case they use indirection and the ValueHolder has not been instantiated.
-