org.eclipse.persistence.queries
Class DeleteAllQuery
java.lang.Object
org.eclipse.persistence.queries.DatabaseQuery
org.eclipse.persistence.queries.ModifyQuery
org.eclipse.persistence.queries.ModifyAllQuery
org.eclipse.persistence.queries.DeleteAllQuery
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class DeleteAllQuery
- extends ModifyAllQuery
Purpose:
Query used to delete a collection of objects
Responsibilities:
- Stores & retrieves the objects to delete.
- Store the where clause used for the deletion.
- See Also:
- Serialized Form
- Author:
- Yvon Lavoie
- Since:
- TOPLink/Java 1.0
Field Summary |
protected java.util.Vector |
objects
|
Fields inherited from class org.eclipse.persistence.queries.DatabaseQuery |
accessor, argumentFields, arguments, argumentTypeNames, argumentTypes, argumentValues, CascadeAggregateDelete, CascadeAllParts, CascadeByMapping, CascadeDependentParts, cascadePolicy, CascadePrivateParts, descriptor, doNotRedirect, executionSession, flushOnExecute, hintString, isCustomQueryUsed, isExecutionClone, isNativeConnectionRequired, isPrepared, isUserDefined, name, NoCascading, properties, queryMechanism, queryTimeout, redirector, session, sessionName, shouldBindAllParameters, shouldCacheStatement, shouldCloneCall, shouldMaintainCache, shouldPrepare, shouldUseWrapperPolicy, sourceMapping, translationRow |
Constructor Summary |
DeleteAllQuery()
PUBLIC: |
DeleteAllQuery(java.lang.Class referenceClass)
PUBLIC:
Create a new delete all query for the class specified. |
DeleteAllQuery(java.lang.Class referenceClass,
Expression selectionCriteria)
PUBLIC:
Create a new delete all query for the class and the selection criteria
specified. |
Method Summary |
java.lang.Object |
executeDatabaseQuery()
INTERNAL:
Perform the work to delete a collection of objects. |
void |
executeDeleteAll(org.eclipse.persistence.internal.sessions.AbstractSession session,
org.eclipse.persistence.internal.sessions.AbstractRecord translationRow,
java.util.Vector objects)
INTERNAL:
Delete all queries are executed specially to avoid cloning and ensure preparing. |
java.lang.Object |
executeInUnitOfWork(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork,
org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
INTERNAL:
This method has to be broken. |
protected QueryRedirector |
getDefaultRedirector()
INTERNAL:
Returns the specific default redirector for this query type. |
java.util.Vector |
getObjects()
PUBLIC:
Return the objects that are to be deleted |
boolean |
isDeleteAllQuery()
PUBLIC:
Return if this is a delete all query. |
protected void |
prepare()
INTERNAL:
Prepare the receiver for execution in a session. |
void |
setObjects(java.util.Vector 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, isModifyQuery, isPreparedUsingTempStorage, mergeChangesIntoSharedCache, setCacheUsage, setExpressionBuilder, setIsPreparedUsingTempStorage, setReferenceClass, setReferenceClassName, setShouldDeferExecutionInUOW, shouldDeferExecutionInUOW, shouldInvalidateCache |
Methods inherited from class org.eclipse.persistence.queries.DatabaseQuery |
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, getArguments, getArgumentTypeNames, getArgumentTypes, getArgumentValues, getCall, getCascadePolicy, getDatasourceCall, getDatasourceCalls, getDescriptor, getDomainClassNounName, getDoNotRedirect, getEJBQLString, getExecutionSession, getFlushOnExecute, getHintString, getJPQLString, getName, getProperties, getProperty, getQueryMechanism, getQueryNounName, getQueryTimeout, getRedirector, getSelectionCriteria, getSensorName, getSession, getSessionName, getShouldBindAllParameters, getSourceMapping, getSQLStatement, getSQLString, getSQLStrings, getTranslatedSQLString, getTranslatedSQLStrings, getTranslationRow, hasAccessor, hasArguments, hasProperties, hasQueryMechanism, hasSessionName, ignoreBindAllParameters, ignoreCacheStatement, isCallQuery, isCascadeOfAggregateDelete, isCustomQueryUsed, isCustomSelectionQuery, isDataModifyQuery, isDataReadQuery, isDefaultPropertiesQuery, isDeleteObjectQuery, isDirectReadQuery, isExecutionClone, isExpressionQuery, isInsertObjectQuery, isJPQLCallQuery, isModifyAllQuery, isNativeConnectionRequired, isObjectBuildingQuery, isObjectLevelModifyQuery, isObjectLevelReadQuery, isPrepared, isReadAllQuery, isReadObjectQuery, isReadQuery, isReportQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isValueReadQuery, isWriteObjectQuery, maintainCache, prepareCall, prepareCustomQuery, prepareForExecution, prepareForRemoteExecution, prepareFromQuery, redirectQuery, remoteExecute, remoteExecute, removeProperty, replaceValueHoldersIn, rowFromArguments, setAccessor, setArguments, setArgumentTypeNames, setArgumentTypes, setArgumentValues, setCall, setCascadePolicy, setDatasourceCall, setDescriptor, setDoNotRedirect, setEJBQLString, setExecutionSession, setFlushOnExecute, setHintString, setIsCustomQueryUsed, setIsExecutionClone, setIsNativeConnectionRequired, setIsPrepared, setIsUserDefined, setJPQLString, setName, setProperties, setProperty, setQueryMechanism, setQueryTimeout, setRedirector, setSelectionCriteria, setSession, setSessionName, setShouldBindAllParameters, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldUseWrapperPolicy, setSourceMapping, setSQLStatement, setSQLString, setTranslationRow, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeByMapping, shouldCascadeOnlyDependentParts, shouldCascadeParts, shouldCascadePrivateParts, shouldCloneCall, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldUseWrapperPolicy, toString |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
objects
protected java.util.Vector objects
DeleteAllQuery
public DeleteAllQuery()
- PUBLIC:
DeleteAllQuery
public DeleteAllQuery(java.lang.Class referenceClass)
- PUBLIC:
Create a new delete all query for the class specified.
DeleteAllQuery
public DeleteAllQuery(java.lang.Class referenceClass,
Expression selectionCriteria)
- PUBLIC:
Create a new delete all query for the class and the selection criteria
specified.
isDeleteAllQuery
public boolean isDeleteAllQuery()
- PUBLIC:
Return if this is a delete all query.
- Overrides:
isDeleteAllQuery
in class DatabaseQuery
executeInUnitOfWork
public java.lang.Object executeInUnitOfWork(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork,
org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
throws DatabaseException,
OptimisticLockException
- 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 class ModifyAllQuery
- Parameters:
unitOfWork
- translationRow
-
- Returns:
-
- Throws:
org.eclipse.persistence.essentials.exceptions.DatabaseException
org.eclipse.persistence.essentials.exceptions.OptimisticLockException
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 DatabaseException
- 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 class DatabaseQuery
- Returns:
- Integer the number of objects (rows) deleted.
- Throws:
DatabaseException
- - an error has occurred on the database.
executeDeleteAll
public void executeDeleteAll(org.eclipse.persistence.internal.sessions.AbstractSession session,
org.eclipse.persistence.internal.sessions.AbstractRecord translationRow,
java.util.Vector objects)
throws DatabaseException
- INTERNAL:
Delete all queries are executed specially to avoid cloning and ensure preparing.
- Throws:
DatabaseException
getDefaultRedirector
protected QueryRedirector 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 class DatabaseQuery
getObjects
public java.util.Vector getObjects()
- PUBLIC:
Return the objects that are to be deleted
prepare
protected void prepare()
throws QueryException
- INTERNAL:
Prepare the receiver for execution in a session.
- Overrides:
prepare
in class DatabaseQuery
- Throws:
QueryException
setObjects
public void setObjects(java.util.Vector objectCollection)
- 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.
#setObject() should not be called.
Vector 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.