850 B
850 B
#jpa
查询条件
使用Persist Object存查询条件
QuestInfoPO po = new QuestInfoPO();
po.setCreatorId(StringUtils.isBlank(creatorId) ? null : creatorId);
po.setCreatedBy(StringUtils.isBlank(creatorName) ? null : creatorName);
po.setName(StringUtils.isBlank(questName) ? null : questName);
po.setStatus(status);
过滤规则
使用ExampleMatch指定过滤规则,matcher的properties使用的是表字段名
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("creator_id", match -> match.exact())
.withMatcher("created_by", match -> match.contains())
.withMatcher("name", match -> match.contains())
.withMatcher("status", match -> match.exact())
.withIgnoreNullValues();
排除空条件
使用withIgnoreNullValues()排除po中的null条件