You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Jiming Liu <ji...@gmail.com> on 2007/07/10 17:47:48 UTC
Batch insert using Mysql, id property did not get out
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;
}
});
}
Fwd: Batch insert using Mysql, id property did not get out
Posted by Jiming Liu <ji...@gmail.com>.
---------- Forwarded message ----------
From: Jiming Liu <ji...@gmail.com>
Date: Jul 10, 2007 11:47 PM
Subject: Batch insert using Mysql, id property did not get out
To: user-java@ibatis.apache.org
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;
}
});
}