8 Replies Latest reply on May 6, 2010 2:20 PM by Juan Pablo Gardella

    Editable Data Table with mass edit features. Unique constraint error

    John Skillings Newbie

      Hello All,

      We started developing an application with Seam recently.  Our application uses large number of editable data tables (mass edit capability).  Here is a URL for the editable data table forms we are developing.

      In this example the base table has 3 columns (id, name, value).  ID has a primary key (sequence), and  name has a unique index.

      The problem we are facing is the on the update of the Name field. We are running into a duplicate key value  violates unique constraint that we need some help or few ideas on how to solve the problem.

      Here is the problem.

      There are few situations where the Name needs to be updated.

      "For e.g.  on Row 1,  Name = 'bgp51y', and Row 2, Name = '7hu2v3';
      Now I update Row 1,  Name = '7hu2v3', and Row 2, Name = 'bgp51y'.  Basically, I am swapping the Name values on Rows 1 and 2."

      When I enter save, I am getting the duplicate key value violates unique constraint error.  It appears that records are saved sequentially, hence the error from database.

      I was assuming that this was a transaction, and all the updates were to be committed at the end. But that does not seems to be case here.  The problem also is that we cannot seem to catch the exception from entity manager.

      Can any one give some ideas on how resolve our problem please.