如何在querydslpredicateexecutor中使用包含忽略大小写?

8yoxcaq7  于 2021-07-23  发布在  Java
关注(0)|答案(1)|浏览(459)

我想要达到的是 IN 在my中忽略大写或小写的查询 QuerydslPredicateExecutor ,但是我找不到这个函数和任何关于它的文档。我是这样做的:

List<String> statusList = new ArrayList<String>();
statusList.add("ASSIGNED");
statusList.add("Got Permit");

QTransStuffing qTransStuffing = QTransStuffing.transStuffing;
BooleanExpression isCanceledFalse = qTransStuffing.cancelStuffing.eq(false);
BooleanExpression eStatusList = qTransStuffing.status.in(statusList);
Predicate predicate = isCanceledFalse.and(eStatusList);

transStuffingRepository.findAll(predicate)

如你所见,如果我们 qTransStuffing.status.in(statusList) 这样就不会忽略大小写,我怎样才能在查询中实现用忽略大小写呢?

qkf9rpyu

qkf9rpyu1#

没有比这更好的方法了:

List<String> statusList = new ArrayList<String>();
statusList.add("ASSIGNED");
statusList.add("GOT PERMIT");

QTransStuffing qTransStuffing = QTransStuffing.transStuffing;
BooleanExpression isCanceledFalse = qTransStuffing.cancelStuffing.eq(false);
BooleanExpression eStatusList = qTransStuffing.status.upperCase().in(statusList);
Predicate predicate = isCanceledFalse.and(eStatusList);

transStuffingRepository.findAll(predicate)

相关问题