Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ADF transaction problem

Scofield WangJan 23 2014 — edited Jan 23 2014

I added such a method in Applicaion Module Impl and it is called by managed bean. updated rows echo "1", but it is really not committed to database although trans.commit() is called. What's wrong?

  public void updateSSPrioritizationImportanceWeightage(ImportanceWeightage[] importanceWeightages) {

       // Transaction jtaTrans = getTransaction();

       

        //System.out.println("jtaTrans.isDirty(): "+  jtaTrans.isDirty());

       

        DBTransaction trans = getDBTransaction();

        PreparedStatement statement = null;

        boolean containError =false;

        String sql = " UPDATE YARD_SETTING SET value_x = ?, setting_type_c = ? WHERE setting_id = ?";

        statement = trans.createPreparedStatement(sql, 2);

        try {

            for(int i = 0; i< importanceWeightages.length; i++){

                statement.setString(1, importanceWeightages[i].getValueX());

                statement.setString(2, "U");

                System.out.println("importanceWeightages[i].getSettingId(): "+ importanceWeightages[i].getSettingId());

                statement.setLong(3, importanceWeightages[i].getSettingId());

                int rows = statement.executeUpdate();

               

                System.out.println("updated rows: "+ rows);

                System.out.println("trans.isDirty(): "+ trans.isDirty());

                trans.commit();

                //System.out.println("jtaTrans.isDirty(): "+  jtaTrans.isDirty());

            }

        } catch (SQLException s) {

            containError = true;

            throw new JboException(s);

        } finally {

            try {

                if (statement != null)

                    statement.close();

            } catch (SQLException s) {

            }

            try {

                if(!containError){

                    trans.commit();

                  //jtaTrans.commit();

                }else{

                    trans.rollback();

                 // jtaTrans.rollback();

                }

            } catch (Exception s) {

            }

        }

    }

MB.

        ImportanceWeightage[] importanceWeightages = populateImportanceWeightages();

        if(importanceWeightages != null){

            OperationBinding ob = getBindings().getOperationBinding("updateSSPrioritizationImportanceWeightage");

            ob.getParamsMap().put("importanceWeightages", importanceWeightages);

            ob.execute(); 

            if(!ob.getErrors().isEmpty()){

               System.out.println(ob.getErrors());

           

            }

        }

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 20 2014
Added on Jan 23 2014
3 comments
165 views