HQL语句为:
select new com.xxx.vo.TAdminDefineReportVo(a.defineReportId,a.reportTmpId,
c.reportName,a.admin,a.reportType,a.description,
a.status,a.createTime,a.autoSend,a.emails,b.userName)
from TAdminDefineReport a,TReportTemplate c,TAdminInfo b
where a.reportTmpId = c.reportTmpId
and a.admin = b.administrorId
and a.admin = ? $queryClause$
order by a.reportTmpId desc,a.createTime desc
DaoImpl类:
public Pagination getAdminRepByAdmId(int admId,String queryName,String reportType,String startTime,String endTime){
try{
String hql = this.getHql("repTmp.hql10");
StringBuilder sb = new StringBuilder();
if(("".equals(queryName)||queryName==null)&&("-1".equals(reportType)||reportType==null)
&&("".equals(startTime)||startTime==null)&&("".equals(endTime)||endTime==null)){
hql = hql.replace("$queryClause$", "");
}
if(!"".equals(queryName) && queryName != null){
sb.append(" and b.reportName like '%" + queryName + "%'");
}
if(!"-1".equals(reportType)&&!"".equals(reportType)){
sb.append(" and a.reportType = '" + reportType + "'");
}
if(!"".equals(startTime) && startTime != null){
sb.append(" and a.createTime >= '" + startTime + "'");
}
if(!"".equals(endTime) && endTime != null){
sb.append(" and a.createTime <= '" + endTime + "'");
}
hql = hql.replace("$queryClause$", sb.toString());
return this.searchPaginated(hql,admId);
}catch(Exception e){
logger.error(e.getMessage());
throw new PersistenceException(e.getMessage());
}
}