How to commit the proper records during Bulk update or Bulk Insert

34 views
Skip to first unread message

Ravi Thapa

unread,
Oct 8, 2012, 12:57:41 PM10/8/12
to mybati...@googlegroups.com

Hi All

I have a scenario, During bulk update or bulk insertion

Say suppose i have 10 records to insert or update that to in bulk, 

I have 9 records which are proper records but the 10th record is having an issue with the column like Data conversion issue or Truncation issue, therefore even the proper records are also rolled back. Because 10th record will result into an error resulting in data conversion or Truncation issue. I don't want any rollback should not happen in this case, 

So how can i resolve this?? I want the proper records to be inserted, where as this is not happening during bulk update or bulk insert.

How can i achieve this in Mybaits??

Thanks and Regards
Ravi

Guy Rouillier

unread,
Oct 8, 2012, 10:55:47 PM10/8/12
to mybati...@googlegroups.com
How are you doing you bulk updates? Are you using ExecutorType.BATCH?
Your program is working as it should. The whole point of batches is to
do a whole group of work followed by a single commit. If any statement
in the batch fails, the whole batch fails.

I don't really understand what you are expecting to happen. How can you
execute a batch of 10 statements, and if one of them fails, commit the
other 9? How would you do such a thing in straight JDBC without MyBatis?
--
Guy Rouillier

Ravi Thapa

unread,
Oct 8, 2012, 11:31:07 PM10/8/12
to mybati...@googlegroups.com
Thanks for replying Guy Rouillier.

Yes i am using ExecutorType.BATCH.

I thought there might be some way to commit proper records, as per your reply i understood that we cannot commit; if any one of the statement fails, I am pretty new to bulk update. I even don't know how i can resolve this in JDBC.
--
Thanks and Regards
Reply all
Reply to author
Forward
0 new messages