CachedRowSetDataProvider Bug when removeRow and appendRow called without commitChanges

Here’s the test case and stack trace

    public String btnTest_action() {

        getMaintdayitemDataProvider().removeRow(getMaintdayitemDataProvider().getCursorRow());
        getMaintdayitemDataProvider().appendRow();
        getMaintdayitemDataProvider().cursorLast(); //
        return null;
    }

java.lang.IllegalArgumentException: CachedRowSetRowKey[2]
        at com.sun.data.provider.impl.CachedRowSetDataProvider.setCursorRow(CachedRowSetDataProvider.java:346)
        at com.sun.data.provider.impl.CachedRowSetDataProvider.cursorLast(CachedRowSetDataProvider.java:415)
        at precisweb.maintday.btnTest_action(maintday.java:678)

6 Responses to “CachedRowSetDataProvider Bug when removeRow and appendRow called without commitChanges”

  1. Mario Ciappara writes:

    I have the same problem when I append a new row and I set the cursor of the cachedRowSetDataProvider to the new rowkey as follows:

    if (cachedRowSetDataProvider1.canAppendRow()) {
    RowKey rk = cachedRowSetDataProvider1.appendRow();
    cachedRowSetDataProvider1.setCursorRow(rk);

    cachedRowSetDataProvider1.setValue(”t.id”, new Integer(0));
    cachedRowSetDataProvider1.setValue(”t.name”, new String(”"));
    cachedRowSetDataProvider1.setValue(”a.id”, new Integer(0));
    cachedRowSetDataProvider1.setValue(”a.hse_no”, new String(”"));
    cachedRowSetDataProvider1.setValue(”a.street_name”, new String(”"));
    }

    I get the following error :

    java.lang.IllegalArgumentException: CachedRowSetRowKey[28]
    at com.sun.data.provider.impl.CachedRowSetDataProvider.setCursorRow(CachedRowSetDataProvider.java:346)
    at test.CustomerAddressEdit.btnNew_action(CustomerAddressEdit.java:464)

  2. Chui writes:

    It’s very annoying bug. Especially for the bread and butter bits of a mature product.

  3. Jesse Pangburn writes:

    I am having the same problem. This seems pretty basic for Sun to have missed. Anyone know if Sun is aware of this, or scheduled to fix in a later release?

  4. Scud writes:

    Having also the same problem. Strange that 1 year after nothing is done. Is Sun abandoning this framework ?

  5. imsld writes:

    try this :
    if (cachedRowSetDataProvider1.canAppendRow()) {
    cachedRowSetDataProvider1.appendRow();
    cachedRowSetDataProvider1.cursorLast();

    cachedRowSetDataProvider1.setValue(”t.id”, new Integer(0));
    cachedRowSetDataProvider1.setValue(”t.name”, new String(””));
    cachedRowSetDataProvider1.setValue(”a.id”, new Integer(0));
    cachedRowSetDataProvider1.setValue(”a.hse_no”, new String(””));
    cachedRowSetDataProvider1.setValue(”a.street_name”, new String(””));
    }

  6. janunezc writes:

    Mario, I see the case you are presenting is very similar to the insert-update-delete tutorial in netbeans.

    What is interesting is, I did that tutorial and worked with no trouble. Then I followed similar steps for a web app I am developing and now I am stuck with the bug…

    @imsld, you are proposing the use of cursorLast() instead of setCursorRow()… I will try it, but I foresee it might show trouble if the rowset is ordered and the last row does not coincide with the new just added.

    I will let you know what I find.

Leave a Reply