返回为List的数组,里面的对象是Permission类型的
HibernateUtil.getSession()
.createQuery(
创建SQL语句的方法。固定的
"from Permission where status=:status")
SQL语句。=:后面是个变量。
.setInteger("status", status)
赋予这个变量
.list();
将得到的结果转成数组
用hql构造query对象 ,query可以设置setfirstresult和maxresult,不要用hibernatetemplate ,hql不用写rownum条件,直接'from 对象class名 where 条件'即可
string hql = " from job where a= " +value;
query q = session.createquery(hql);
q.setfirstresult 0;
q.setmaxresult 1;
list result= q.list();