13 Ответы Последний ответ: 10.07.2020 21:11, автор: ILya Cyclone

    inmemory sorting + Rollback blows up my table

    ILya Cyclone

      Hi.

      I have a usecase: a ui table with few rows, ordered by PositionIndex attribute. Each row has buttons UP and DOWN to reorder rows by modifying PositionIndex.

      If I click UP on second row it should exchange PositionIndex with a row above, so after that row2 will have PositionIndex==1 and row1 will have PositionIndex==2 and the rows are reordered in ui table.

      After that I can commit or rollback changes.

       

      I implemented it so that UP and DOWN call exposed view object method via binding and the method is modifying PositionIndex of current and next/previous row and reexecutes query.

       

      ViewObjectImpl
          public void move(Key key, boolean up) {
              Row currentRow = findByKey(key, 1)[0];
      
      
              RowSetIterator rsi = this.createRowSetIterator(null);
              rsi.setCurrentRow(currentRow);
              
              // here goes some logic but it is not needed for testcase
              
              rsi.closeRowSetIterator();
      
      
              this.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
              this.setSortBy(PREFERENCE_INDEX);
              this.executeQuery();
          }
      

       

      The thing works. I can click UP and DOWN buttons and rows' PositionIndex changes correctly and rows are reordered in UI table.

      If I click Commit, everything is saved to DB correctly.

       

      But If after calling "move" method I click Rollback, estimatedRowCount of table's iterator suddenly becomes 0 and all rows disappear. Even though they are still present in DB.

      Rollback button itself doesn't cause any problems - only in conjunction with "move" method.

       

      I'm not perfectly sure about these rows.

       

      this.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);

      this.setSortBy(POSITION_INDEX);

      this.executeQuery();

       

      Their purpose is to reflect rows reordering on fly (before calling Commit). I think I read it in some blogs a while ago. Like here: https://blogs.oracle.com/imc/adf-bussiness-components:-in-memory-sorting-and-filtering

      But without them rows are not getting reordered in UI.

       

      Records are already created at start of this usecase. Nothing about creating records in this transaction, only modifying.

      Rollback button is standard resetButton with bindings.Rollback.execute, nothing special.

       

      What causes this strange behavior?

       

      Thanks.

      ADF 12.2.1.3