首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

Hibernate的VO在HQL话语中的应用

2012-08-02 
Hibernate的VO在HQL语句中的应用HQL语句为:select new com.xxx.vo.TAdminDefineReportVo(a.defineReportId

Hibernate的VO在HQL语句中的应用

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());
??}
?}

热点排行