9 Replies Latest reply: Mar 31, 2013 1:51 AM by RaviNuka RSS

    Another user has changed the row with primary key oracle.jbo.Key[xx]

    RaviNuka
      Hello Everyone,

      I am trying to update an entity based view object from one my AM methods and it started throwing "Another user has changed the row with primary key" error after adding it. I am assuming it is because of entity cache didn't get updated. This goes in a pattern, first time if I hit save button, it saves, second time it throws error, third time it saves, fourth time it throws error again.

      Note: On the other side, if I set the entity attribute properties (refresh after update & refresh after insert = true) then this error don't occurs but I am not sure if this is a good practice to set these properties and how they are going to impact the performance of application.

      Can someone let me know if I am doing anything wrong in below code

      my sample code in AM method is as below.
      ----------------------------------------------
      EdContractsHdrVORowImpl contractHdr = (EdContractsHdrVORowImpl)this.getEdContractsHdrVO1().getCurrentRow();
      Integer currRevision = contractHdr.getRevisionNumber();
      status = status == null ? "PENDING-APPROVAL" : status;
      if(status.equalsIgnoreCase("REJECTED")){
      if(currRevision > 1)
      contractHdr.setStatus("IN-REVISION");
      else
      contractHdr.setStatus("NEW");
      }else{
      contractHdr.setStatus(status);
      }
      if(status.equalsIgnoreCase("APPROVED") ){
      if(contractHdr.getApprovedByUserName() == null){
      contractHdr.setApprovedByUserName(contractHdr.getModifiedByUserName());
      }
      if(contractHdr.getApprovedDate() == null){
      contractHdr.setApprovedDate(contractHdr.getUpdateDate());
      }

      }

      getDBTransaction().commit();

      --------------------------------

      Thanks,
      Ravi N