项目中一个好用的查找方法,基于HSQL和一个HSQL构造器。
java 代码
- public Page findBy(PageInfo pageInfo) {
- return findBy("from KbsEntry as a where 1=1 "+
- "/~ and a.number like '%[number]%' ~/"+
- "/~ and a.subject like '%[subject]%' ~/"+
- "/~ and a.content like '%[content]%' ~/"+
- "/~ and a.keyword like '%[keyword]%' ~/"+
- "/~ and a.type = {type} ~/"+
- "/~ and a.status = {status} ~/"+
- "/~ and a.satisfaction = {satisfaction} ~/"+
- "/~ and a.satisfyCount = {satisfyCount} ~/"+
- "/~ and a.clickCount = {clickCount} ~/"+
- "/~ and a.createTime = {createTime} ~/"+
- "/~ and a.modifyTime = {modifyTime} ~/"+
- "/~ and a.kbsEntryAdjust = {kbsEntryAdjust} ~/"+
- "/~ and a.kbsAttachments = {kbsAttachments} ~/"+
- "/~ and a.kbsUser.id = {kbsUserId} ~/"+
- "/~ and a.kbsSort.id = {kbsSortId} ~/"+
- "/~ and a.modifier.id = {modifierId} ~/"+
- "/~ and a.author.id = {authorId} ~/"+
- // 根据产品查找条目
- "/~ and a in (select elements(kp.kbsEntries) from KbsProduct kp where kp.id = {kbsProductId}) ~/"+
- "/~ and a.kbsSort in (select elements(vr.kbsSorts) from KbsVisitorRole vr where vr.id = {visitorRoleId}) ~/"+
- "/~ order by [sortingColumn] [sortingDirection] ~/",pageInfo);
- }