public List<?> findAllProject(int rowsPerPage, int page) {//This method must return a result of type List<?>显示红线错误
Session session=null;
try {
session=HbSessionFactory.getSession();
Query query=session.createQuery("from Project");
query.setMaxResults(rowsPerPage);
query.setFirstResult(rowsPerPage*(page-1));
List<?> list=query.list();
return list;
} catch (HibernateException e) {
e.printStackTrace();
}finally{
HbSessionFactory.closeSession(session);
}
}
上面的错误该怎么解决?

解决方案 »

  1.   

    在方法的最后返回一个空,如下:public List <?> findAllProject(int rowsPerPage, int page) {//This method must return a result of type List <?>显示红线错误 
    Session session=null; 
    try { 
    session=HbSessionFactory.getSession(); 
    Query query=session.createQuery("from Project"); 
    query.setMaxResults(rowsPerPage); 
    query.setFirstResult(rowsPerPage*(page-1)); 
    List <?> list=query.list(); 
    return list; 
    } catch (HibernateException e) { 
    e.printStackTrace(); 
    }finally{ 
    HbSessionFactory.closeSession(session); 

    return null;

      

  2.   

    public List <?> findAllProject(int rowsPerPage, int page) {//This method must return a result of type List <?>显示红线错误 
    Session session=null; 
    List list = null;
    try { 
    session=HbSessionFactory.getSession(); 
    Query query=session.createQuery("from Project"); 
    query.setMaxResults(rowsPerPage); 
    query.setFirstResult(rowsPerPage*(page-1));  
    list=query.list(); 
    } catch (HibernateException e) { 
    e.printStackTrace(); 
    }finally{ 
    HbSessionFactory.closeSession(session); 

    return list;