Friday, April 3, 2009

Row.STATUS_INITIALIZED

We were experiencing a very strange problem with an OA page. The page is used to update multiple rows from a transient VO using a table region. Following were the symptoms.
  • Sometimes after save, the old value used to reappear.
  • Sometimes after save, value from different row gets updated to current row.
  • It was not happening for all kind of data.

Finally (by sheer luck) we found that it was because the way we preparing the VO for update.

Old Code
Row row = vo.createRow();
row.setAttribute(0,"value1");
row.setAttribute(1,"value2");
row.setNewRowState(row.STATUS_INITIALIZED);
vo.insertRow(row);

It seems we accidentally were using STATUS_INTITIALIZED instead of STATUS_NEW. What a bummer?

I am not sure where or when we should be using STATUS_INTITIALIZED though but found out that it should never be used while preparing row for insert or update. Below is from the javadoc of oracle.jbo.Row.








static byte
STATUS_INITIALIZED



Indicates that the row is newly created and no setAttribute has been called on it yet.

static byte
STATUS_NEW



Indicates that the Row is newly created and this Row's consistuent entities have been added to the transaction.


No comments: