在HQL中可以使用"?"和":***"的方式在外部配置查询参数,如:
Query query=session.createQuery("from TestStu s where s.team=:team and s.age>:age");
或者Query query=session.createQuery("from TestStu s where s.team=? and s.age>?);
传递参数:
query.setEntity("team",team);或query.setEntity(0,team);
query.setParameter("age", 15);或query.setParameter(1, 15);