当前位置: 代码迷 >> J2EE >> 无语…用Spring的getJdbcTemplate的query方法返回的List为空!但是在数据库执行sql语句有结果,求解!该怎么解决
  详细解决方案

无语…用Spring的getJdbcTemplate的query方法返回的List为空!但是在数据库执行sql语句有结果,求解!该怎么解决

热度:61   发布时间:2016-04-22 02:14:22.0
无语……用Spring的getJdbcTemplate的query方法返回的List为空!但是在数据库执行sql语句有结果,求解!
如题!
  望大虾解答!
以下是我的代码:
Java code
@SuppressWarnings("unchecked")    public PageModel<Book> findByTypeName(int pageNo, int pageSize,            String typename) {        String sql = "select * from ("            + " select *,row_number() over(order by pubtime) rownum "            + " from new_book  where typename = ?) temp "            + " where rownum between ? and ?";                List<Book> all = new ArrayList<Book>();        PageModel<Book> pageModel = new PageModel<Book>();                int counts = this.getTotalRecords("select count(1) from new_book where typename = " + typename);                if(counts <=0) {            return null;        } else {            pageModel.setTotalRecords(counts);            pageModel.setTotalPages();            pageModel.setPageNo(pageNo);                        int start = pageModel.getPageSize()*(pageModel.getPageNo()-1) + 1;            int end = pageModel.getPageSize()*pageModel.getPageNo();                        all = getJdbcTemplate().queryForList(sql, new Object[] {typename ,start, end});System.out.println(sql + " " + start + " " + end + " " + typename + " " + counts);            System.out.println("List 大小:" + all.size());                        pageModel.setList(all);                        return pageModel;        }    }


------解决方案--------------------
查询本来就没结果败
------解决方案--------------------
你确定吗?看下条件有没有放错位置吧
------解决方案--------------------
那你看看参数传的都对吗?getJdbcTemplate() 是不是空的
  相关解决方案