日期:2014-05-17  浏览次数:20644 次

关于回调函数
Java code

public List<UserLog> findUserLog(final int userId){
        return this.getHibernateTemplate().executeFind(new HibernateCallback() {
            
            public Object doInHibernate(Session session) throws HibernateException,
                    SQLException {
                // TODO Auto-generated method stub
                Query q=session.createQuery("from UserLog where userId="+userId+" order by logId desc");
                q.setMaxResults(10);
                q.setFirstResult(0);
                System.out.println("总条数:"+q.list().size());
                return q.list();
            }
        });
}



已继承HibernateDaoSupport
SessionFactory有getset方法
错误信息
 Error creating bean with name 'userBlogsDaoImpl' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required

请问是哪里错了?

------解决方案--------------------
是你spring的配置文件有问题,不是回调的问题
------解决方案--------------------
userBlogsDaoImpl 未定义 检查下applicationContext.xml