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