Closed GoogleCodeExporter closed 9 years ago
that's nothing effect!
the value returned of the method doUpdate has no using,the realy result of
update effect's rows is the method doFlushStatements returned!!!
Original comment by kuaiyuel...@gmail.com
on 19 Sep 2010 at 6:34
So, I can't understand how I should use the ExecutorType.BATCH and the
documentation doesn't help me.
I write the sample code below but it doesn't work properly: it executes the
doUpdate method of BatchExecutor and returns the strange value described in
first post, but it works.
Could anybody make an example that return me the number of entries updated?
thanks
SqlSession session = getSession(ExecutorType.BATCH);
List entries = session.selectList("getAllEntries");
int upd = 0;
for (Object object : entries) {
myObj obj = (myObj) object;
obj.setColumn(update);
upd += session.update("updateSingleEntry", obj);
}
return upd;
myObj is:
public class myObj implements Serializable {
private String key;
private String value;
public void setKey(String key) {
this.key= key;
}
public String getKey() {
return key;
}
public void setValue(String value) {
this.value= value;
}
public String getValue() {
return value;
}
}
the query is:
<update id="updateSingleEntry" parameterType="org.sample.myObj">
UPDATE
TEST_TABLE
SET
VALUE=#{value}
WHERE
KEY=#{key}
</update>
Original comment by giat...@hotmail.com
on 21 Sep 2010 at 4:06
I am afraid you can't.
When you use a batch SqlSession, statements are not executed until you call
.commit() so there is no way to return results. You will just get exceptions if
something goes wrong.
Original comment by eduardo.macarron
on 16 Feb 2011 at 3:24
Original issue reported on code.google.com by
giat...@hotmail.com
on 6 Sep 2010 at 1:25