Business Objects and Data Sources > Data Sources > Grouping Changes in Batches

You can make changes to the contents of a data source or to business objects by grouping them into batches. In this way, changes are handled more efficiently and provide improved performance. You can batch additions and removals of objects, as well as changes to the business objects themselves, such as changes in the containment structure, link extremities or attribute values.

How to Batch Changes
IlpAbstractDataSource datasource = ...
...
datasource.startBatch();
// add/remove objects
// update attribute values, change containment, change link extremities
...
datasource.endBatch();

Data source changes that are grouped in a batch are delayed until the call to endBatch.

Batches can be nested. In this case, changes are delayed until the most enclosing call to endBatch().

How to Nest Batches
datasource.startBatch();
    datasource.startBatch();
    // first batch
    ...
    datasource.endBatch();
    datasource.startBatch();
    // second batch
    ...
    datasource.endBatch();
datasource.endBatch();
How to Batch Changes in XML

Data source changes in XML streams can be grouped in batches using the element <batch> as illustrated in the following sample:

   <cplData>
      <batch>
         <addObject>
            <!-- ... -->
         </addObject>
         <updateObject>
            <!-- ... -->
         </updateObject>
         <removeObject>
            <!-- ... -->
         </removeObject>
      </batch>
   </cplData>

Batches can also be nested in data source XML streams by nesting <batch> elements. In this case, changes are delayed until the most enclosing </batch>.