2 Replies Latest reply: Sep 10, 2013 2:13 AM by user10124642 RSS

    Default and secondary row sets not working as expected


      I am trying the following code to understand how the default and secondary row sets work in ADF. However, the implementation doesn't seem straightforward.


      public void testRowSets(){
        CountryVOImpl vo = (CountryVOImpl)findViewObject("Countries");
        vo.setbindRegionId(new Integer(4));
        RowSetIterator iter1 = vo.getRowSetIterator();
        while (iter1.hasNext()){
        System.out.println("default iterator, for region id 4, has countries="+iter1.next().getAttribute("CountryName")); //prints Zimbabwe,Nigeria,Israel
        RowSet rowSet = vo.createRowSet("secondaryRowSet");
        vo.setbindRegionId(new Integer(4));  
        while (rowSet.hasNext()){
        System.out.println("secondary row set, for region id 4, has countries="+rowSet.next().getAttribute("CountryName")); //prints nothing
        RowSetIterator iter = vo.getRowSetIterator();
        System.out.println("default row set iterator row count="+iter.getEstimatedRangePageCount());
        while (iter.hasNext()){
        System.out.println("default row set iterator, for region id 4, has countries="+iter.next().getAttribute("CountryName"));


      Now, iter1 prints X, Y, and Z country names (line #9).The secondary row set prints no countries (line #17). After executeQuery() on the secondary row set, the default row set iterator also prints nothing (line #25). Believe the secondary row set has a different query collection only as long as the row filter is different, and in the case above it's the same. But if that's the case then when we perform rowSet.executeQuery in QUERY_MODE_SCAN_VIEW_ROWS, why does it not see the records in the default row set which have already been placed in the cache by iteration over the default row set?


      NOTE: Changed the subject in the hope to get more suggestions/answers

        • 1. Re: Default and secondary row sets

          have you tried resetting the rowset after the first iteration - my guess its pointing to the end after the first iteration. So perhaps try closing the rowsetitertor first


          iter1 .closeRowSetIterator();


          and then


          RowSetIterator iter=vo.createRowSetIterator('secondaryRowSetIterator')
          • 2. Re: Default and secondary row sets

            Thanks, but it didn't work. Would expect it not to, as for the new row set we are performing executeQuery() which would put the iterator back before the first record. Also, in any case it's a secondary iterator, and so even if it is pointing to the same Query Collection, it should not be affected by the processing on the default iterator.


            The following line (#19) has been returning 0 records with/without the change: iter.getEstimatedRangePageCount()