弄得头大的ibatis批量删除终于搞定了,
原来错误一直是没有把页面传过来的string转成数组,原来一直以为就是数组,
,比如页面传进来的id是这样的“dfsfsdfsdf-sfsdfsdf,asdasdsadsa-asdasdasdas”;代表有两个要删除,每一个用逗号间隔,网上的都写得不全我这样应该算全了,哈哈哈
public boolean test(String id) {
String [] ids=id.split(",");
try {
SqlMapClient client = IbatisFactory.getSqlMapClient();
client.delete("test", ids);
return true;
} catch (SQLException ex) {
ex.printStackTrace();
return false;
}
}
<delete id="test" >
delete from tablename where id in (
<iterate conjunction=",">#[]#</iterate>)
</delete>
![](/images/smiles/icon_biggrin.gif)
![](/images/smiles/icon_rolleyes.gif)
public boolean test(String id) {
String [] ids=id.split(",");
try {
SqlMapClient client = IbatisFactory.getSqlMapClient();
client.delete("test", ids);
return true;
} catch (SQLException ex) {
ex.printStackTrace();
return false;
}
}
<delete id="test" >
delete from tablename where id in (
<iterate conjunction=",">#[]#</iterate>)
</delete>