4 Replies Latest reply: Jan 21, 2013 12:26 AM by PreethamChandra RSS

    Updating ROW and inserting multiple row

    PreethamChandra
      Hello,

      I needed some help.

      Firstly, i have VO which has 2 EO, these 2 EO are linked with association.

      In my page, i have a table, which by default has one row, and few fields can be edited, on click of "Apply" i want to commit this data,
      but when i use " getOADBTransaction().commit();" it gives me primary key constraint error.


      Secondly, when i click on add row button, it adds new row with unique primary key, also copying few attributes from existing first row.
      So, now when i want to update this table, since this VO is based on 2 EO's which are linked , i can't insert completely since in second EO parent EO's primary key is not inserted.

      Please help.
        • 1. Re: Updating ROW and inserting multiple row
          Sushant Sharma
          Hi,

          How are you setting the primary keys of those tables ? Are these being populated thru some sequence ?

          --Sushant                                                                                                                                                                                                                                                       
          • 2. Re: Updating ROW and inserting multiple row
            PreethamChandra
            I'm not getting any error.


            But data is not getting reflecting in DB.

            getOADBTransaction().commit() is not throwing any error.
            But in DB its not inserted.

            Edited by: PreethamChandra on Jan 18, 2013 3:39 AM
            • 3. Re: Updating ROW and inserting multiple row
              Sushant Sharma
              Hi,

              Can you share you code where you have initialized the VO for inserting a new row ?

              --Sushant                                                                                                                                                                                                           
              • 4. Re: Updating ROW and inserting multiple row
                PreethamChandra
                I created new VO.
                It is EO based.


                Again, Commit is not working.


                code is


                public void create_row()
                {
                SplitAtsVOImpl svo = getSplitAtsVO1();
                Row row = svo.first();
                Row r = svo.createRow();
                for(int i =1;i<row.getAttributeCount();i++)
                {System.out.println(i+"          "+row.getAttribute(i));
                           if(row.getAttribute(i)!=null&&i<27)
                         r.setAttribute(i,row.getAttribute(i).toString());
                          }


                r.setAttribute("DispAssNum",""+r.getAttribute("AssetNum")+"-"+count);
                r.setAttribute("AtsAssetId",getOADBTransaction().getSequenceValue("ATS_ASSET_TBL_S").toString());
                System.out.println(r.getAttribute("AtsAssetId"));
                r.setNewRowState(Row.STATUS_INITIALIZED);
                //r.setAttribute("AtsAssetId1",(""+row.getAttribute("AtsAssetId")));
                System.out.println(svo.getRowCount());
                svo.insertRowAtRangeIndex(0,r);

                try
                {
                getOADBTransaction().commit();

                }

                catch(OAException e)
                {
                System.out.println(e.toString());
                }

                }