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!

How to insert multiple rows to entityImpl in ADF

lacmanMay 19 2015 — edited May 21 2015

Hi,

1. Database is MYSQL.

2. Created a Entity Object and created the code using Auto Increment for the primary key attribute (WEEKLY_ID)

3. I created method in AMImpl.java to insert multiple rows to the EOImpl.java.

4. I am looping using a for(...) loop and trying to insert the row to EOImpl.java.

5. If i just have one value in the map then there are no issues inserting the data.

6. If i've mutiple value in the map then i get the following error:

Iterating for the second time in the loop "trx.commit()" errors. Do I need to reset the WeeklyEOImpl ?

oracle.jbo.DMLException: JBO-26041: Failed to post data to database during "Insert": SQL Statement "INSERT INTO WEEKLY(WEEKLY_ID,DAY_ID,CREATED_BY,UPDATED_BY,CREATED_DATE,UPDATED_DATE) VALUES (?,?,?,?,?,?)".

AMImpl.java

updateEo(Map inputMap){

        DBTransaction trx = this.getDBTransaction();

        Object weekDays = inputMap.get("DaysList");

        EntityDefImpl entityDefImpl =WeeklyEOImpl.getDefinitionObject();

        if (weekDays != null) {

            List<String> weekDayList = (ArrayList<String>)weekDays;

            for (String weekDay : weekDayList) {

               WeeklyEOImpl wkly  = (WeeklyEOImpl)entityDefImpl.createInstance2(trx, null);

                wkly  .setCreatedBy(new BigDecimal(inputMap.get("UserId").toString()));

                wkly  .setUpdatedBy(new BigDecimal(inputMap.get("UserId").toString()));

                wkly  .setCreatedDate(getCurrentDate());

                wkly  .setUpdatedDate(getCurrentDate());

                wkly  .setDayId(new BigDecimal(weekDay));

                trx.commit();

            }

        }

}

Regards,

Lacman

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 18 2015
Added on May 19 2015
3 comments
531 views