public int find2(String hql){ final String hql1 = hql; try{ this.getHibernateTemplate().execute(new HibernateCallback(){ //执行查询操作 public Object doInHibernate(Session session) throws HibernateException,sqlException { list = session.createQuery(hql1).list(); return list; } }); int num=(Integer) list.get(0); return num; }catch(Exception e){ e.printStackTrace(); return 0; } }原文链接:https://www.f2er.com/javaschema/286034.html