execute(HibernateCallback action)
引數說明:public TbUser getUser(final Integer ID){ HibernateTemplate htm = getHibernateTemplate(); TbUser user = (TbUser)htm.execute(new HibernateCallback(){ public Object doInHibernate(Session session)throws HibernateException,SQLException{ Object user = session.get(TbUser.class,ID); return user; } }); return user; //返回TbUser物件 }