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

## org.objectstyle.cayenne.query
Class BatchQuery

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

All Implemented Interfaces:
  java.io.Serializable, Query

Direct Known Subclasses:
  DeleteBatchQuery, InsertBatchQuery, UpdateBatchQuery

    public abstract class BatchQuery

extends java.lang.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.

Author:
  Andriy Shapochka, Andrus Adamchik
See Also:
  Serialized Form

Field Summary
`protected int` | `batchIndex`
`protected DbEntity` | `dbEntity`
`protected java.lang.String` | `name`

Constructor Summary
`BatchQuery(DbEntity dbEntity)`

Method Summary
`SQLAction` | `createSQLAction(SQLActionVisitor visitor)` Calls "batchAction" on the visitor.
`abstract java.util.List` | `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.
`java.lang.String` | `getName()` Returns a symbolic name of the query.
`java.lang.Object` | `getObject(int valueIndex)` Deprecated. Since 1.2 renamed to "getValue()"
`ObjectId` | `getObjectId()` Returns an ObjectId associated with the current batch iteration.
`java.lang.Object` | `getRoot()` Deprecated. since 1.2 as the corresponding interface method is also deprecated.
`abstract java.lang.Object` | `getValue(int valueIndex)` Returns a value at a given index for the current batch iteration.
`protected java.lang.Object` | `getValue(java.util.Map valueMap, DbAttribute attribute)` A helper method used by subclasses to resolve deferred values on demand.
`java.util.List` | `getValuesForUpdateParameters(boolean includeNullValues)` Deprecated. Since 1.2 use BatchQueryBuilder.getParameterValues(), as this allows better control over which attributes are logged.
`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` | `setName(java.lang.String name)` Sets a symbolic name of the query.
`void` | `setRoot(java.lang.Object root)` Deprecated. since 1.2
`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 java.lang.String name

Constructor Detail

### BatchQuery

    public BatchQuery(DbEntity dbEntity)

Method Detail

### getName

    public java.lang.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(java.lang.String name)

  Description copied from interface: `Query`
  Sets a symbolic name of the query.

  Specified by:
    `setName` in interface `Query`

### getMetaData

    public QueryMetadata getMetaData(EntityResolver resolver)

  Returns default select parameters.

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

### getRoot

    public java.lang.Object getRoot()

  Deprecated. since 1.2 as the corresponding interface method is also deprecated.

  Description copied from interface: `Query`
  Returns the root object of the query.

  Specified by:
    `getRoot` in interface `Query`

### setRoot

    public void setRoot(java.lang.Object root)

  Deprecated. since 1.2

  Description copied from interface: `Query`
  Sets the root of the query.

  Specified by:
    `setRoot` in interface `Query`

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

### getValuesForUpdateParameters

    public java.util.List getValuesForUpdateParameters(boolean includeNullValues)

  Deprecated. Since 1.2 use BatchQueryBuilder.getParameterValues(), as this allows better control over which attributes are logged.

  Returns a List of values for the current batch iteration, in the order they are bound to the query. Used mainly for logging.

  Parameters:
    `includeNullValues` - A `true` value indicates that the returned list should include `null` values and `false` indicates they should not be included.

### isEmpty

    public boolean isEmpty()

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

### getDbAttributes

    public abstract java.util.List 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.

### getObject

    public java.lang.Object getObject(int valueIndex)

  Deprecated. Since 1.2 renamed to "getValue()"

### getValue

    public abstract java.lang.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 java.lang.Object getValue(java.util.Map 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 | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 ObjectStyle.org All Rights Reserved.