hql查询

来源:互联网 发布:数据脱敏处理方法 编辑:程序博客网 时间:2024/06/10 03:33
假设你的院,系,班级分别为 institution,department,clazz都分别为字符串类型。在student表中。那么可以按照如下方式构造hql语句student 里面封装了从文本框中接受的参数,提供get,set方法,当然是任意组合的了String hql = "from Student s where s.institution like:inst" + " and s.department like:depa " + " and s.clazz like:claz";Query query = session.createQuery(hql); query.setString("inst", "%" +student.getInstitution() + "%"); query.setString("depa", "%" + local.getDepartment() + "%"); query.setString("claz", "%" + local.getClazz() + "%");List<Student> list=query.list();
原创粉丝点击