Skip navigation links

Oracle TopLink Java API Reference
10g Release 3 (10.1.3.1)

B28219-01


oracle.toplink.queryframework
Class UpdateAllQuery

java.lang.Object
  extended byoracle.toplink.queryframework.DatabaseQuery
      extended byoracle.toplink.queryframework.ModifyQuery
          extended byoracle.toplink.queryframework.UpdateAllQuery

All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class UpdateAllQuery
extends ModifyQuery

PUBLIC: A Query Class used to perform a bulk update using TopLink's expression framework. This class is provided to help optimize performance. It can be used in place of reading in all the objects to be changed and issuing single updates per instance. With this approach a single SQL UPDATE statement can be issued and then, based on the Expression provided, any objects in the cache that are effected by the update can be invalidated.

Notes:

Example of Usage: Adding an area code.
UpdateAllQuery updateQuery = new UpdateAllQuery(Employee.class);
updateQuery.setSelectionCriteria(eb.get("areaCode").isNull());
updateQuery.addUpdate(eb.get("areaCode"), "613");

See Also:
Serialized Form

Field Summary
static int INVALIDATE_CACHE
          Cache usage flag indicating that there are objects in the cache which are invalid.
static int NO_CACHE
          Cache usage flag indicating that the cache is valid.

 

Fields inherited from class oracle.toplink.queryframework.DatabaseQuery
CascadeAggregateDelete, CascadeAllParts, CascadeByMapping, CascadeDependentParts, CascadePrivateParts, NoCascading

 

Constructor Summary
UpdateAllQuery()
          PUBLIC: Constructs a default update all query.
UpdateAllQuery(java.lang.Class referenceClass)
          PUBLIC: Constructs an update all query for the Class type specified.
UpdateAllQuery(java.lang.Class referenceClass, Expression selectionCriteria)
          PUBLIC: Constructs an update all query for the specified Class type and selection criteria.
UpdateAllQuery(java.lang.Class referenceClass, ExpressionBuilder builder)
          PUBLIC: Constructs an update all query for the Class type specified and the given ExpressionBuilder.

 

Method Summary
 void addUpdate(Expression field, Expression value)
          PUBLIC: Adds the update (SET) clause to the query.
 void addUpdate(Expression field, java.lang.Object value)
          PUBLIC: Adds the update (SET) clause to the query.
 void addUpdate(java.lang.String attributeName, java.lang.Object value)
          PUBLIC: Adds the update (SET) clause to the query.
 int getCacheUsage()
          PUBLIC: Returns the cache usage for this update all query.
 ExpressionBuilder getExpressionBuilder()
          PUBLIC: Returns the expression builder which should be used for this update all query.
 java.lang.Class getReferenceClass()
          PUBLIC: Returns the reference Class type for this update all query.
 void setCacheUsage(int cacheUsage)
          PUBLIC: Sets the level of cache support for this query.
 void setExpressionBuilder(ExpressionBuilder builder)
          PUBLIC: Sets the expression builder which should be used for this update all query.
 void setReferenceClass(java.lang.Class referenceClass)
          PUBLIC: Sets the reference class for this update all query.
 void setShouldDeferExecutionInUOW(boolean shouldDeferExecutionInUOW)
          PUBLIC: Sets a flag indicating whether the execution of the update all query should be deferred until the UOW commits.
 boolean shouldDeferExecutionInUOW()
          PUBLIC: Returns a boolean indicating whether the query's execution is deferred in a UOW until it commits.

 

Methods inherited from class oracle.toplink.queryframework.ModifyQuery
forceBatchStatementExecution, isModifyQuery, setForceBatchStatementExecution

 

Methods inherited from class oracle.toplink.queryframework.DatabaseQuery
addArgument, addArgument, addArgument, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, cacheStatement, cascadeAllParts, cascadeByMapping, cascadePrivateParts, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, getCall, getCalls, getDatasourceCall, getDatasourceCalls, getEJBQLString, getHintString, getName, getQueryTimeout, getRedirector, getSelectionCriteria, getSessionName, getSQLStatement, getSQLString, getSQLStrings, getTranslatedSQLString, getTranslatedSQLStrings, hasSessionName, ignoreBindAllParameters, ignoreCacheStatement, isCallQuery, isDataModifyQuery, isDataReadQuery, isDeleteObjectQuery, isExpressionQuery, isInsertObjectQuery, isObjectLevelModifyQuery, isObjectLevelReadQuery, isReadAllQuery, isReadObjectQuery, isReadQuery, isReportQuery, isSQLCallQuery, isUpdateObjectQuery, isWriteObjectQuery, maintainCache, prepareCall, setCall, setDatasourceCall, setEJBQLString, setHintString, setName, setQueryTimeout, setRedirector, setSelectionCriteria, setSessionName, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldUseWrapperPolicy, setSQLStatement, setSQLString, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeByMapping, shouldCascadeParts, shouldCascadePrivateParts, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldUseWrapperPolicy, toString

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

NO_CACHE

public static final int NO_CACHE
Cache usage flag indicating that the cache is valid.
See Also:
Constant Field Values

INVALIDATE_CACHE

public static final int INVALIDATE_CACHE
Cache usage flag indicating that there are objects in the cache which are invalid. This is the default value when an update all query is instantiated.
See Also:
Constant Field Values

Constructor Detail

UpdateAllQuery

public UpdateAllQuery()
PUBLIC: Constructs a default update all query.

UpdateAllQuery

public UpdateAllQuery(java.lang.Class referenceClass)
PUBLIC: Constructs an update all query for the Class type specified.
Parameters:
referenceClass - Class

UpdateAllQuery

public UpdateAllQuery(java.lang.Class referenceClass,
                      Expression selectionCriteria)
PUBLIC: Constructs an update all query for the specified Class type and selection criteria.
Parameters:
referenceClass - Class type to be considered
selectionCriteria - Expression

UpdateAllQuery

public UpdateAllQuery(java.lang.Class referenceClass,
                      ExpressionBuilder builder)
PUBLIC: Constructs an update all query for the Class type specified and the given ExpressionBuilder. This builder must be used for all associated expressions used with the query.
Parameters:
referenceClass - Class type to be considered
builder - ExpressionBuilder

Method Detail

addUpdate

public void addUpdate(Expression field,
                      java.lang.Object value)
PUBLIC: Adds the update (SET) clause to the query.
Parameters:
field - Expression Object level representation of a database query 'where' clause
value - Object, the new value

addUpdate

public void addUpdate(java.lang.String attributeName,
                      java.lang.Object value)
PUBLIC: Adds the update (SET) clause to the query.
Parameters:
attributeName - String, the name of the attribute
value - Object, the new value

addUpdate

public void addUpdate(Expression field,
                      Expression value)
PUBLIC: Adds the update (SET) clause to the query. This method ensures that the builder has the session and reference class set for both given Expressions.
Parameters:
field - Expression, representation of a database query 'where' clause that describes the field
value - Expression, representation of a database query 'where' clause that describes the new value

getCacheUsage

public int getCacheUsage()
PUBLIC: Returns the cache usage for this update all query.
Returns:
int - UpdateAllQuery.NO_CACHE or UpdateAllQuery.INVALIDATE_CACHE depending on whether the cache is currently valid

getExpressionBuilder

public ExpressionBuilder getExpressionBuilder()
PUBLIC: Returns the expression builder which should be used for this update all query. Note: This expression builder should be used to build all expressions used by this query. If a builder does not yet exist, this method will initialize one.
Returns:
ExpressionBuilder, used to create Expressions

getReferenceClass

public java.lang.Class getReferenceClass()
PUBLIC: Returns the reference Class type for this update all query.
Overrides:
getReferenceClass in class DatabaseQuery
Returns:
Class under consideration with this query

setCacheUsage

public void setCacheUsage(int cacheUsage)
PUBLIC: Sets the level of cache support for this query.
Parameters:
cacheUsage - int value, UpdateAllQuery.NO_CACHE or UpdateAllQuery.INVALIDATE_CACHE

setExpressionBuilder

public void setExpressionBuilder(ExpressionBuilder builder)
PUBLIC: Sets the expression builder which should be used for this update all query. This expression builder should be used to build all expressions used by this query.
Parameters:
builder - ExpressionBuilder

setReferenceClass

public void setReferenceClass(java.lang.Class referenceClass)
PUBLIC: Sets the reference class for this update all query.
Parameters:
referenceClass - Class

setShouldDeferExecutionInUOW

public void setShouldDeferExecutionInUOW(boolean shouldDeferExecutionInUOW)
PUBLIC: Sets a flag indicating whether the execution of the update all query should be deferred until the UOW commits.
Parameters:
shouldDeferExecutionInUOW - boolean - set to true if execution in UOW is to be deferred

shouldDeferExecutionInUOW

public boolean shouldDeferExecutionInUOW()
PUBLIC: Returns a boolean indicating whether the query's execution is deferred in a UOW until it commits.
Returns:
boolean - true if execution in UOW is being deferred

Skip navigation links

Copyright © 1998, 2006, Oracle. All Rights Reserved.