org.apache.cayenne.query

## 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 DataObjects.
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class org.apache.cayenne.query.BatchQuery

      `dbAttributes, dbEntity, rows`

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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 org.apache.cayenne.query.BatchQuery

      `createSQLAction, getDbAttributes, getDbEntity, getMetaData, getRows, isUsingOptimisticLocking, route`

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### InsertBatchQuery

          public InsertBatchQuery(DbEntity entity,
                                  int batchCapacity)

      Creates new InsertBatchQuery for a given DbEntity and estimated capacity.

  - ### Method Detail

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

Copyright © 2001–2021 Apache Cayenne. All rights reserved.