executeFind(HibernateCallback action)
引數說明:public List getSmallUser(final Integer ID){ HibernateTemplate htm = getHibernateTemplate(); final String sql = "FROM TbUser u where u.age<18"; //生成一條SQL語句 List list = htm.executeFind(new HibernateCallback(){ public Object doInHibernate(Session session)throws HibernateException,SQLException{ Query query = session.createQuery(sql); List list = query.list(); return list; } }); //建立一個List集合接收查詢結果 return list; }