String hql = " from  TbA as t where t.waiId in (?) and t.startTime >=? and t.endTime <=?  order by t.id asc";
    waiId 是Integer类型   那么  第一个参数如何设置?  我设置成 "1,2"  只是返回 当等于 1 的结果。 2的结果没有了。    

解决方案 »

  1.   

     t.startTime >=? and t.endTime <=?betwween t.startTime and  t.endTime    better
      

  2.   

    String hql = " from TbA as t where t.waiId in ("+"1,2"+") and t.startTime >=? and t.endTime <=? order by t.id asc"; 楼主这样写好像可以用Collection对象,我没用过
      

  3.   

     //把参数存入数组
     String   vals[]=new   String[]{"1","2","3"};   
        //指定参数名为ids
     String hql = " from  TbA as t where t.waiId in (:ids) and t.startTime >=? and t.endTime <=?  order by t.id asc"; 
     
     Query   query   =   session.createQuery(hql);   
     
     query.setParameters(ids,vals);query.set.......//其它参数return query.list();
      

  4.   

    补充点:可能会有参数类型问题,
    //把参数存入数组,如果String不行就要这样: Integer vals[]=new Integer[]{1,2,3};