项目中一个好用的查找方法,基于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);
- }
本文介绍了一种基于HSQL和HSQL构造器的高效查找方法。该方法通过灵活组合多个查询条件,实现对数据库中特定记录的有效检索。具体包括按编号、主题、内容等字段进行模糊匹配,同时支持对类型、状态等精确条件的筛选。
1116

被折叠的 条评论
为什么被折叠?



