---------- Forwarded message ----------
From: Jiming Liu <[EMAIL PROTECTED]>
Date: Jul 10, 2007 11:47 PM
Subject: Batch insert using Mysql, id property did not get out
To: [email protected]

Hi guys,

There have an id, which is auto_increment filed in table city of a mysql db
.

The insert("insertCity", v); method works correct, since it works fine in
non-batch mode.

But in the following batch code. All the id is 0, which is initilized by -1.
That means iBatis do set the value but do not know the right value. What
shall I do to get the value?

Best regards,

Jiming



   public Object insert(int mender_id, final List<City> value, final
boolean use_current_time) {
       return template.execute(new SqlMapClientCallback() {
           public Object doInSqlMapClient(SqlMapExecutor executor) throws
SQLException {
               executor.startBatch();
               for(City v: value) {
                   executor.insert("insertCity", v);
               }
               List result = null;
               try {
                   result = executor.executeBatchDetailed();
               } catch (BatchException e) {
                   throw ex;
               }
               return result;
           }
       });
   }

Reply via email to