首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

求一句 简略的HQL ,关于in

2011-12-19 
求一句 简单的HQL ,关于inString hql fromTbA as t where t.waiId in (?) and t.startTime ? and t.

求一句 简单的HQL ,关于in
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的结果没有了。

[解决办法]
String hql = " from TbA as t where t.waiId in ("+"1,2"+") and t.startTime >=? and t.endTime <=? order by t.id asc"; 

楼主这样写好像可以用Collection对象,我没用过
[解决办法]
楼主这样写in(?,?)不就可以了么
[解决办法]
 


Java code
//把参数存入数组 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(); 

热点排行