日期:2014-05-20  浏览次数:20905 次

SSH Hibernate返回值问题
代码是SSH框架,需要运行一个包括有聚合函数count 并进行group by 的sql语句。从Hibernate运行的总数量来看都是正确的,和SQL Sverver 查询分析器里的到的结果一致。但是在jsp页面里无法显示这个count计算的结果,具体代码如下:
ACTION

public String GetJustcrawledConfList() throws UnsupportedEncodingException{
    int totalRow = tconferenceService.getRowstemp(TConference.class, "id", ......);
    pager = pagerService.getPager(currentPage, pagerMethod, totalRow);     
    this.setCurrentPage(String.valueOf(pager.getCurrentPage()));
    this.setTotalRows(String.valueOf(totalRow));  
    System.out.println("String.valueOf(totalRow)=="+String.valueOf(totalRow));
    availableItems = tconferenceService.queryItemstemp(TConference.class, "id", ..... pager.getPageSize(), pager.getStartRow());    return SUCCESS;
}



public List<T> queryEntityItemstemp(Class<T> entityClass, ID id, ArrayList<String> fieldnameList, ArrayList<String> valueList, int pageSize, int startRow){
final int pageSize1 = pageSize;
final int startRow1 = startRow;
final String entityname = entityClass.getName();
String hql="select a.conferenceid, a.conferencename,count(b.id) as count from meetings.ssh.model.TConference as a,meetings.ssh.model.TConferencedocument as b where a.ifcrawl=1 and a.ifanalysis =0 and b.conferenceid = a.conferenceid group by a.conferenceid,a.conferencename order by count(b.id) desc";
final String hql1 = hql;
return this.getHibernateTemplate().executeFind(new HibernateCallback() {
public List doInHibernate(Session session)
throws HibernateExceptionSQLException {
Query query = session.createQuery(hql1);
if (startRow1 >= 0 && pageSize1 >= 0) {
query.setFirstResult(startRow1);
query.setMaxResults(pageSize1);
}
return query.list();
}
});
}




  <s:iterator value="availableItems" status="meeting">
   <td align="left"><a href="${conferenceurl}" target="_blank"><s:property value="conferencename" /></a>[<s:property value="conferenceid" />]</td>

------解决方案--------------------
<s:iterator value="availableItems" status="meeting">//确保红色的能取到值?
改为value="%{availableItems}"看下
------解决方案--------------------
现在客户端里测试下,再往上面写