ibatis批量删除

来源:互联网 发布:java中标签的作用 编辑:程序博客网 时间:2024/05/21 02:36
弄得头大的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>

0 0
原创粉丝点击