InsertBatchQuery (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.query, class: InsertBatchQuery

# Class InsertBatchQuery

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

All Implemented Interfaces:
  `Serializable, Query`

public class InsertBatchQuery extends BatchQuery
Batched INSERT query. Allows inserting multiple object snapshots (DataRows) for a given DbEntity in a single query. InsertBatchQuery normally is not used directly. Rather DataContext creates one internally when committing Persistent objects.

See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class BatchQuery

  `dbAttributes, dbEntity, rows`
  Modifier and Type
  Field
  Description
  `protected List<DbAttribute>`
  `dbAttributes`
  `protected DbEntity`
  `dbEntity`
  `protected List<BatchQueryRow>`
  `rows`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `InsertBatchQuery(DbEntity entity, int batchCapacity)`
  Creates new InsertBatchQuery for a given DbEntity and estimated capacity.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(Map<String,Object> snapshot)`
  Adds a snapshot to batch.
  `void`
  `add(Map<String,Object> snapshot, ObjectId id)`
  Adds a snapshot to batch.

  ### Methods inherited from class BatchQuery

  `createSQLAction, getDbAttributes, getDbEntity, getMetaData, getRows, isUsingOptimisticLocking, route`
  Modifier and Type
  Method
  Description
  `SQLAction`
  `createSQLAction(SQLActionVisitor visitor)`
  Calls "batchAction" on the visitor.
  `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.
  `List<BatchQueryRow>`
  `getRows()`
  `boolean`
  `isUsingOptimisticLocking()`
  Returns true if the batch query uses optimistic locking.
  `void`
  `route(QueryRouter router, EntityResolver resolver, Query substitutedQuery)`
  A callback method invoked by Cayenne during the routing phase of the query execution.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### InsertBatchQuery

    public InsertBatchQuery(DbEntity entity, int batchCapacity)
    Creates new InsertBatchQuery for a given DbEntity and estimated capacity.

- ## Method Details

  - ### add

    public void add(Map<String,Object> snapshot)
    Adds a snapshot to batch. A shortcut for "add(snapshot, null)".

  - ### add

    public void add(Map<String,Object> snapshot, ObjectId id)
    Adds a snapshot to batch. Optionally stores the object id for the snapshot. Note that snapshot can hold either the real values or the instances of java.util.Supplier that will be resolved to the actual value on the spot, thus allowing deferred propagated keys resolution.
    Since:
      1.2