{"id":2906,"date":"2017-12-21T14:00:43","date_gmt":"2017-12-21T20:00:43","guid":{"rendered":"http:\/\/www.designandexecute.com\/designs\/?p=2906"},"modified":"2018-12-21T14:23:00","modified_gmt":"2018-12-21T20:23:00","slug":"how-to-overcome-the-select-top-1000-issue-with-the-java-businessobjects-sdk","status":"publish","type":"post","link":"https:\/\/www.designandexecute.com\/designs\/how-to-overcome-the-select-top-1000-issue-with-the-java-businessobjects-sdk\/","title":{"rendered":"How to overcome the select top 1000 issue with the Java businessObjects SDK"},"content":{"rendered":"<p>the default rows to return is 1000 rows for the query builder queries in the BO SDK.\u00a0 there a few ways to manage this<\/p>\n<ol>\n<li>is the easily way is to hard code the value eg &#8220;select top 20000 SI_ID from CI_SYSTEMOBJECTS&#8221;, 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.<\/li>\n<li>the better way is the lazy loading the query by the 1000&#8217;s.\u00a0 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.\u00a0 It would be totally WORM and the lazy reads helps the system recover per query.<\/li>\n<\/ol>\n<p>here is an example of how this can be expanded to work for you.<\/p>\n<p>public static HashMap&lt;String, CMSUser&gt; getMembers (IInfoStore infoStore, String userGroup) throws SDKException {<\/p>\n<p>bolean fullBucket = true;<\/p>\n<p>int\u00a0lastUserId =\u00a0 0;<\/p>\n<p>while (fullBucket) {<\/p>\n<p>IInfoBObject iinfoObjectUser = null;<\/p>\n<p>try {<\/p>\n<p>iinfoObjectUser\u00a0 =\u00a0infoStore.query(&#8220;select top 1000 SI_ID from CI_SYSTEMOBJECTS where CHILDREN(\\&#8221;SI_NAME=&#8217;User-Group-User'&#8221;, \\&#8221;SI_NAME=&#8217;userGroup&#8217;\\&#8221;) and SI_ID &gt; &#8221; + lastUserId + &#8221; order by SI_ID ASC&#8221;);<\/p>\n<p>int numOfUser = infoObjectsUsers.size();<\/p>\n<p>fullBucket = (numOfUser\u00a0 ==1000?true:false);<\/p>\n<p>if (numOfUser &gt; 0) {<\/p>\n<p>IUser lastUser = (IUser) infoObjUser.get(numOfUser -1);<\/p>\n<p>lastUserId =\u00a0lastUser.getId();<\/p>\n<p>for (int I=0; I &lt;\u00a0numOfUser; I++) {<\/p>\n<p>IUser tempInfoUser = (IUser ) infoObjects.get(I);<\/p>\n<p>Date cDate = (Date) (tempInfoUser.propertities().getProperty(&#8220;SI_CREATION_TIME&#8221;) != null ?\u00a0tempInfoUser.propertities().getProperty(&#8220;SI_CREATION_TIME&#8221;).getValue: new Date(0));<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>} catch {<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>the default rows to return is 1000 rows for the query builder queries in the BO SDK.\u00a0 there a few ways to manage this is the easily way is to hard code the value eg &#8220;select top 20000 SI_ID from CI_SYSTEMOBJECTS&#8221;, the draw back is the system takes a performance hit, and the hard coded [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":4904,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,30,28],"tags":[],"class_list":["post-2906","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bi-dashboards-analytics","category-bi-business-objects","category-java-hibernate"],"jetpack_featured_media_url":"https:\/\/www.designandexecute.com\/designs\/wp-content\/uploads\/2018\/12\/sap-bo-sdk.png","_links":{"self":[{"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/posts\/2906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/comments?post=2906"}],"version-history":[{"count":5,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/posts\/2906\/revisions"}],"predecessor-version":[{"id":4909,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/posts\/2906\/revisions\/4909"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/media\/4904"}],"wp:attachment":[{"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/media?parent=2906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/categories?post=2906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/tags?post=2906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}