How to overcome the select top 1000 issue with the Java businessObjects SDK

0
1096
businesss objects java sdk

the default rows to return is 1000 rows for the query builder queries in the BO SDK.  there a few ways to manage this

  1. is the easily way is to hard code the value eg “select top 20000 SI_ID from CI_SYSTEMOBJECTS”, the draw back is the system takes a performance hit, and the hard coded value does not follow the WORM (write once read many) theory. if you got to 21, 000 you would need to update your code of parameter file.
  2. the better way is the lazy loading the query by the 1000’s.  If you read 1000 per query and track the last record read then read the next 1000 and do this until there are no more records to retrieve.  It would be totally WORM and the lazy reads helps the system recover per query.

here is an example of how this can be expanded to work for you.

public static HashMap<String, CMSUser> getMembers (IInfoStore infoStore, String userGroup) throws SDKException {

bolean fullBucket = true;

int lastUserId =  0;

while (fullBucket) {

IInfoBObject iinfoObjectUser = null;

try {

iinfoObjectUser  = infoStore.query(“select top 1000 SI_ID from CI_SYSTEMOBJECTS where CHILDREN(\”SI_NAME=’User-Group-User'”, \”SI_NAME=’userGroup’\”) and SI_ID > ” + lastUserId + ” order by SI_ID ASC”);

int numOfUser = infoObjectsUsers.size();

fullBucket = (numOfUser  ==1000?true:false);

if (numOfUser > 0) {

IUser lastUser = (IUser) infoObjUser.get(numOfUser -1);

lastUserId = lastUser.getId();

for (int I=0; I < numOfUser; I++) {

IUser tempInfoUser = (IUser ) infoObjects.get(I);

Date cDate = (Date) (tempInfoUser.propertities().getProperty(“SI_CREATION_TIME”) != null ? tempInfoUser.propertities().getProperty(“SI_CREATION_TIME”).getValue: new Date(0));

}

}

} catch {

}

}

 

}