There are a few ways around the iteration with commit problem. I’m waiting for
details on one of them but I can describe two others.
The first is to use sailpoint.api.IdIterator instead of calling context.search() and iteratoring over that result set.
class sailpoint.api.IdIterator {
public <T extends SailPointObject> IdIterator(SailPointContext context, Class<T> cls, QueryOptions ops)
throws GeneralException {
The intereface is similar to context.search() youy provide the class you want to iterate on
and a QueryOptions object that contains any filters you may want. In this example I won’t include
any filters.
IdIterator it = new IdIterator(context, Identity.class, null);
What this does is read in ALL of the id columns for rows in the Identity table. You can
then iterate over this committing as you go and the result will be preserved because we
no longer have an open cursor.
while (it.hasNext() {
String id = it.next();
Identity obj = context.getObjectById(Identity.class, id);
... do something with the identity
}
For any type of iteration over a large number of objects it is important to do a periodic
full session decache in order to prevent cache bloat. IdIterator will do this automatically
after every 100 objects. This can be changed.
A slightly easier interace is sailpoint.api.IncrementalObjectIteratyor. This wraps IdIterator and saves the step of calling getObject().
IncrementalObjectIterator it = new IncrementalObjectIterator(context, Identity.class, options);
while (it.hasNext()) {
Identity obj = it.next();
...
}
With either of these, you will always have a stable result to iterate over and can commit or rollback within the loop.