List<Integer> lst = new ArrayList<Integer>(); lst.add(14); lst.add(15); lst.add(17); String hql = "from Students s where s.SId in (:lst)"; Query q = session.createQuery(hql); q.setParameterList("lst",lst); // 以一个实类作为参数条件 hql = "from Students s where s.class=:class"; q.setEntity("class",session.get(Class.class,1)); // 根据给的参数匹配对应的类型Type hiberntae里的类 hql = "from Students s where s.SId=? or s.SName=?"; Query q = session.createQuery(hql); q.setParameters(new Object [] { 14,"update" },new Type [] { new IntegerType(),new StringType() }); |