1、通过关联的表的某字段查询和排序
表的关系
代码
/**
*
* <p>Description:查找作业记录</p>
* <p>Paramenter:</p>
* <p>Return:</p>
* <p>Exception:</p>
* <p>Modified History: </p>
*/
public String getHomeworkList(){
if(firstQuery){
//如果是第一次查询则设置查询时间
queryTime = System.currentTimeMillis();
}
QueryPage queryPage = new QueryPage(pageSize,pageIndex,null,null);
queryPage.addEqualSearch("userId",super.getCurrentUserId());
queryPage.addEqualSearch("state", state);
queryPage.addAliasLessEqualSearch("homework", "a", "createTime", new Date(queryTime));
queryPage.addAliasSort("homework", "a", "createTime", "desc");
homeworkRecordViewVoList = homeworkBiz.getHomeworkList(queryPage, state);
//设置分页信息
String pageUrl = "/homework/getHomeworkList.action";
pageBean = new PageBean(queryPage.getTotalRows(), queryPage.getPageIndex(), queryPage.getPageSize(), pageUrl);
String pageBeanParamters = "queryTime="+queryTime+"&firstQuery=false&state="+state;
pageBean.setParamters(pageBeanParamters);
return state;
}