Consider code
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);
}
Is there anything wrong with above code? In eclipse Helios it is showing following error:
The type new HibernateCallback(){} must implement the inherited abstract method HibernateCallback.doInHibernate(Session)
doInHibernate() is implemented then why it showing the above error?
Make sure that
Sessionisorg.hibernate.Session, not something else (e.g.org.hibernate.classic.Session).The pair of
org.hibernate.Sessionandorg.hibernate.classic.Sessionis especially tricky – since the latter interface extends the former one, accidential mistake of this kind doesn’t cause other problems and cannot be easily noticed.