这篇随笔将会记录hql的常用的查询语句,为日后查看提供便利. 在这里通过定义了三个类,Special.Classroom.Student来做测试,Special与Classroom是一对多,Classroom与Student是一对多的关系,这里仅仅贴出这三个bean的属性代码: Special类: public class Special { private int id; private String name; private String type; private Set<Classro…
HQL查询: public Object query(String name){ Session s=null; try{ s=HibernateSessionFactory.getSession(); //String hql="from User where name=?"; //Query q=s.createQuery(hql); //q.setString(0, name); String hql="from User where name=:name";…