org.apache.cayenne.query
Class UpdateBatchQuery

java.lang.Object
  extended by org.apache.cayenne.query.BatchQuery
      extended by org.apache.cayenne.query.UpdateBatchQuery
All Implemented Interfaces:
Serializable, Query

public class UpdateBatchQuery
extends BatchQuery

Batched UPDATE query.

See Also:
Serialized Form

Field Summary
protected  List<ObjectId> objectIds
           
protected  List<Map> qualifierSnapshots
           
protected  List<Map> updateSnapshots
           
protected  boolean usingOptimisticLocking
           
 
Fields inherited from class org.apache.cayenne.query.BatchQuery
batchIndex, dbEntity, name
 
Constructor Summary
UpdateBatchQuery(DbEntity dbEntity, List<DbAttribute> qualifierAttributes, List<DbAttribute> updatedAttribute, Collection<String> nullQualifierNames, int batchCapacity)
          Creates new UpdateBatchQuery.
 
Method Summary
 void add(Map qualifierSnapshot, Map<?,?> updateSnapshot)
          Adds a parameter row to the batch.
 void add(Map qualifierSnapshot, Map<?,?> updateSnapshot, ObjectId id)
          Adds a parameter row to the batch.
 Map getCurrentQualifier()
          Returns a snapshot of the current qualifier values.
 List<DbAttribute> getDbAttributes()
          Returns a list of DbAttributes describing batch parameters.
 ObjectId getObjectId()
          Returns an ObjectId associated with the current batch iteration.
 List<DbAttribute> getQualifierAttributes()
           
 List<DbAttribute> getUpdatedAttributes()
           
 Object getValue(int dbAttributeIndex)
          Returns a value at a given index for the current batch iteration.
 boolean isNull(DbAttribute attribute)
          Returns true if a given attribute always has a null value in the batch.
 boolean isUsingOptimisticLocking()
          Returns true if the batch query uses optimistic locking.
 void setUsingOptimisticLocking(boolean usingOptimisticLocking)
           
 int size()
          Returns the number of parameter rows in a batch.
 
Methods inherited from class org.apache.cayenne.query.BatchQuery
createSQLAction, getDbEntity, getMetaData, getName, getValue, isEmpty, next, reset, route, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectIds

protected List<ObjectId> objectIds
Since:
1.2

qualifierSnapshots

protected List<Map> qualifierSnapshots

updateSnapshots

protected List<Map> updateSnapshots

usingOptimisticLocking

protected boolean usingOptimisticLocking
Constructor Detail

UpdateBatchQuery

public UpdateBatchQuery(DbEntity dbEntity,
                        List<DbAttribute> qualifierAttributes,
                        List<DbAttribute> updatedAttribute,
                        Collection<String> nullQualifierNames,
                        int batchCapacity)
Creates new UpdateBatchQuery.

Parameters:
dbEntity - Table or view to update.
qualifierAttributes - DbAttributes used in the WHERE clause.
nullQualifierNames - DbAttribute names in the WHERE clause that have null values.
updatedAttribute - DbAttributes describing updated columns.
batchCapacity - Estimated size of the batch.
Method Detail

isNull

public boolean isNull(DbAttribute attribute)
Returns true if a given attribute always has a null value in the batch.

Since:
1.1

isUsingOptimisticLocking

public boolean isUsingOptimisticLocking()
Returns true if the batch query uses optimistic locking.

Overrides:
isUsingOptimisticLocking in class BatchQuery
Since:
1.1

setUsingOptimisticLocking

public void setUsingOptimisticLocking(boolean usingOptimisticLocking)
Since:
1.1

getValue

public Object getValue(int dbAttributeIndex)
Description copied from class: BatchQuery
Returns a value at a given index for the current batch iteration.

Specified by:
getValue in class BatchQuery

add

public void add(Map qualifierSnapshot,
                Map<?,?> updateSnapshot)
Adds a parameter row to the batch.


add

public void add(Map qualifierSnapshot,
                Map<?,?> updateSnapshot,
                ObjectId id)
Adds a parameter row to the batch.

Since:
1.2

size

public int size()
Description copied from class: BatchQuery
Returns the number of parameter rows in a batch.

Specified by:
size in class BatchQuery

getDbAttributes

public List<DbAttribute> getDbAttributes()
Description copied from class: BatchQuery
Returns a list of DbAttributes describing batch parameters.

Specified by:
getDbAttributes in class BatchQuery

getUpdatedAttributes

public List<DbAttribute> getUpdatedAttributes()
Since:
1.1

getQualifierAttributes

public List<DbAttribute> getQualifierAttributes()
Since:
1.1

getCurrentQualifier

public Map getCurrentQualifier()
Returns a snapshot of the current qualifier values.

Since:
1.1

getObjectId

public ObjectId getObjectId()
Returns an ObjectId associated with the current batch iteration. Used internally by Cayenne to match current iteration with a specific object and assign it generated keys.

Overrides:
getObjectId in class BatchQuery
Since:
1.2


Copyright © 2001-2011 Apache Cayenne. All Rights Reserved.