Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.query
Class BatchQuery

    java.lang.Object
      org.apache.cayenne.query.BatchQuery

All Implemented Interfaces:
  Serializable, ConfigurationNode, Query

Direct Known Subclasses:
  DeleteBatchQuery, InsertBatchQuery, UpdateBatchQuery

    public abstract class BatchQuery

extends Object
implements Query

BatchQuery and its descendants allow to group similar data for the batch database modifications, including inserts, updates and deletes. Single BatchQuery corresponds to a parameterized PreparedStatement and a matrix of values.

See Also:
  Serialized Form

Field Summary
`protected int` | `batchIndex`
`protected DataMap` | `dataMap`
`protected DbEntity` | `dbEntity`
`protected String` | `name`

Constructor Summary
`BatchQuery(DbEntity dbEntity)`

Method Summary
`
`<T> T`
` | `acceptVisitor(ConfigurationNodeVisitor<T> visitor)`
`SQLAction` | `createSQLAction(SQLActionVisitor visitor)` Calls "batchAction" on the visitor.
`DataMap` | `getDataMap()`
`abstract List<DbAttribute>` | `getDbAttributes()` Returns a list of DbAttributes describing batch parameters.
`DbEntity` | `getDbEntity()` Returns a DbEntity associated with this batch.
`QueryMetadata` | `getMetaData(EntityResolver resolver)` Returns default select parameters.
`String` | `getName()` Returns a symbolic name of the query.
`ObjectId` | `getObjectId()` Returns an ObjectId associated with the current batch iteration.
`abstract Object` | `getValue(int valueIndex)` Returns a value at a given index for the current batch iteration.
`protected Object` | `getValue(Map<String,Object> valueMap, DbAttribute attribute)` A helper method used by subclasses to resolve deferred values on demand.
`boolean` | `isEmpty()` Returns `true` if this batch query has no parameter rows.
`boolean` | `isUsingOptimisticLocking()` Returns true if the batch query uses optimistic locking.
`boolean` | `next()` Repositions batch to the next object, so that subsequent calls to getObject(int) would return the values of the next batch object.
`void` | `reset()` Rewinds batch to the first parameter row.
`void` | `route(QueryRouter router, EntityResolver resolver, Query substitutedQuery)` A callback method invoked by Cayenne during the routing phase of the query execution.
`void` | `setDataMap(DataMap dataMap)`
`void` | `setName(String name)`
`abstract int` | `size()` Returns the number of parameter rows in a batch.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### batchIndex

    protected int batchIndex

Since:
  1.2

### dbEntity

    protected DbEntity dbEntity

Since:
  1.2

### name

    protected String name

### dataMap

    protected DataMap dataMap

Since:
  3.1

Constructor Detail

### BatchQuery

    public BatchQuery(DbEntity dbEntity)

Method Detail

### acceptVisitor

    public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor)

  Specified by:
    `acceptVisitor` in interface `ConfigurationNode`

### getName

    public String getName()

  Description copied from interface: `Query`
  Returns a symbolic name of the query. The name may be used as a key to find queries stored in the DataMap. Some query implementors reuse the name as a QueryMetadata cache key. Generally the name can be null.

  Specified by:
    `getName` in interface `Query`

### setName

    public void setName(String name)

### getDataMap

    public DataMap getDataMap()

  Specified by:
    `getDataMap` in interface `Query`
  Since:
    3.1

### setDataMap

    public void setDataMap(DataMap dataMap)

  Since:
    3.1

### getMetaData

    public QueryMetadata getMetaData(EntityResolver resolver)

  Returns default select parameters.

  Specified by:
    `getMetaData` in interface `Query`
  Since:
    1.2

### route

    public void route(QueryRouter router,
                      EntityResolver resolver,
                      Query substitutedQuery)

  Description copied from interface: `Query`
  A callback method invoked by Cayenne during the routing phase of the query execution. Mapping of DataNodes is provided by QueryRouter. Query should use a `QueryRouter.route(QueryEngine, Query, Query)` callback method to route itself. Query can create one or more substitute queries or even provide its own QueryEngine to execute itself.

  Specified by:
    `route` in interface `Query`
  Since:
    1.2

### createSQLAction

    public SQLAction createSQLAction(SQLActionVisitor visitor)

  Calls "batchAction" on the visitor.

  Specified by:
    `createSQLAction` in interface `Query`
  Since:
    1.2

### isUsingOptimisticLocking

    public boolean isUsingOptimisticLocking()

  Returns true if the batch query uses optimistic locking.

  Since:
    1.1

### getDbEntity

    public DbEntity getDbEntity()

  Returns a DbEntity associated with this batch.

### isEmpty

    public boolean isEmpty()

  Returns `true` if this batch query has no parameter rows.

### getDbAttributes

    public abstract List<DbAttribute> getDbAttributes()

  Returns a list of DbAttributes describing batch parameters.

### reset

    public void reset()

  Rewinds batch to the first parameter row.

### next

    public boolean next()

  Repositions batch to the next object, so that subsequent calls to getObject(int) would return the values of the next batch object. Returns `true` if batch has more objects to iterate over, `false` otherwise.

### getValue

    public abstract Object getValue(int valueIndex)

  Returns a value at a given index for the current batch iteration.

  Since:
    1.2

### size

    public abstract int size()

  Returns the number of parameter rows in a batch.

### getValue

    protected Object getValue(Map<String,Object> valueMap,
                              DbAttribute attribute)

  A helper method used by subclasses to resolve deferred values on demand. This is useful when a certain value comes from a generated key of another master object.

  Since:
    1.2

### 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.

  Default implementation simply returns null.

  Since:
    1.2

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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