问题:
动态查询需要判断参数是否为空
方案:
查了一些资料,但是并没有完全解决掉,如果参数为null的时候,会直接报类型错误如果后续解决会记录、如有大佬能解决可以留个足迹
SELECT
md.ID,
md.documentno,
md.documenttitle,
md.creator,
md.issuingunit,
md.issuetime,
md.documentstatus,
md.readingsituation,
md.readingsituation,
md.notes,
md.documentcontent,
md.updatetime,
md.orgcode,
md.districtcode,
md.orgname
FROM
mine.mis_document AS md,
( SELECT ID FROM mine.mis_document AS ms WHERE ms.issuingunit LIKE : CONDITION AND ms.documentstatus = '1' ) AS mn
WHERE
mn.ID = md.ID
AND ( : title IS NULL OR : title = '' OR md.documenttitle LIKE : title )
//这个位置可以 : startTime IS NOT NULL 但是测试发现并没有生效
AND ( : startTime IS NULL OR : startTime = '' OR to_char( md.issuetime, 'yyyy-MM-dd' ) >= : startTime )
AND ( : endTime IS NULL OR : endTime = '' OR to_char( md.issuetime, 'yyyy-MM-dd' ) <= : endTime )
ORDER BY
md.issuetime DESC
其他方法查询,但是对时间查询不是很友好
MisCoursePO mis = new MisCoursePO();
mis.setCoursetype("4");
mis.steCourseName("百科");
ExampleMatcher exampleMatcher = ExampleMatcher.matching()
.withMatcher("courseName", GenericPropertyMatchers.contains()) //姓名采用“开始匹配”的方式查询
.withIgnorePaths("id"); //忽略属性
Example<MisCoursePO> of = Example.of(mis, exampleMatcher);
List<MisCoursePO> list= misCourseDao.findAll(of);