0
public List<Product> listProducts(){
HibernateCallback callBack=new HibernateCallback(){
public Object doInHibernate(Session session){
Query query=session.createQuery("from Product");
return query.list();
}
};
return (List<Product>)hibernateTemplate.execute(callBack);
}
這有什麼錯與上面的代碼?在蝕太陽神它顯示以下錯誤:
The type new HibernateCallback(){} must implement the inherited abstract method HibernateCallback.doInHibernate(Session)
doInHibernate()
被實現,那麼爲什麼它示出了上述錯誤?
確保'Session'是'org.hibernate.Session',而不是別的(例如'org.hibernate.classic.Session')。 – axtavt
@axtavt:是的,我錯誤地做了這個。以上的改變已經解決了這個問題。你能不能請你發表評論作爲回答,以便我可以接受? –
以答案形式發佈。 – axtavt