CachedRowSetDataProvider Bug when removeRow and appendRow called without commitChanges
Monday, 26 March 2007
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)
No. 1 — March 30th, 2007 at 10:18 pm
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)
No. 2 — April 2nd, 2007 at 12:05 pm
It’s very annoying bug. Especially for the bread and butter bits of a mature product.
No. 3 — July 6th, 2007 at 12:24 pm
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?
No. 4 — October 1st, 2008 at 11:04 am
Having also the same problem. Strange that 1 year after nothing is done. Is Sun abandoning this framework ?
No. 5 — November 6th, 2008 at 12:14 am
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(””));
}
No. 6 — November 16th, 2008 at 1:55 pm
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.