public boolean deleteCommodityType(int[] ids) {
// TODO Auto-generated method stub
Session session = sf.getCurrentSession();
session.createQuery("delete from commodityType ct where ct.id in (:ids)").setParameter("ids", ids).executeUpdate();
}ids是一个int数组,网上找了一下好像是HQL语句的问题。求解!谢谢。HQL语句问题SSHDELETE IN

解决方案 »

  1.   

    delete from commodityType ct where
    这from很抢眼。去掉
      

  2.   

    和from没有关系,我把后面的  :ids换成具体数值没有问题。应该是后面ids的问题。
      

  3.   

    setParameter("ids", ids)
    你的ids是数组的对象啊,如果这样的话你得到的是ids,不是ids的数组值。
    楼主你遍历一下数组拼接成 符合 in (*) 里的格式就OK了。
      

  4.   

    主要想知道 HQL里面  in的用法。如何把字符串  或  整型数组传进去。应该不用拼接也能实现in .
      

  5.   

     在传递一个集合的索引集或者是元素集(elements与indices 函数) 或者传递一个子查询的结果的时候,可以使用SQL函数any, some, all, exists, inselect mother from Cat as mother, Cat as kit
    where kit in elements(foo.kittens)