问题描述
我有以下工作正常的规范:
Specification<TransactionRequestEntity> specification = Specification
.where(specificationBySourceFundAccountId(requestDto.getSourceFundAccountId()))
.and(specificationByReason(requestDto.getReason()))
.and(specificationByAmount(requestDto.getAmount()))
.and(specificationByMetadata(requestDto.getMetadata())
.and(specificationByDate(requestDto.getDate())));
List<TransactionRequestEntity> transactionRequestEntities = transactionRequestsRepository
.findAll(specification);
我正在尝试优化查询并传递一个原因字符串列表而不是单个原因,并且如果列表中的任何字符串匹配以获取对象。 这是规范的原因,它也按预期工作
public static Specification<TransactionRequestEntity> specificationByReason(String reason) {
return (root,query,builder) -> builder.equal(root.get(REASON),reason);
}
所以我试图用一个原因字符串列表替换原因字符串,但我不确定什么是最好的方法。它是查询还是查询构建器。我还发现有 in() 方法,但到目前为止无法使其工作
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)