skip to main content
Programmers documentation > Business objects and data sources > Data sources > Grouping changes in batches
 
Grouping changes in 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>.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.