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