假设List<Integer>a;a里面已经有数据了,则HQL查询条件可以为:

String hql = "from Tab o where o.id in (:id)";  
 
Query q ;

List<Integer> idList = new ArrayList<Integer>();
idList.add(1);
idList.add(2);

q.setParameterList("id", idList);

重点是设置参数的时候要用setParameterList

设置参数的时候,idList还可以是数组,如int[]idInt