动态查询同个属性
程序员文章站
2022-05-09 11:40:19
...
Query orQuery =newQuery();Criteria orCriteria =newCriteria();List<Criteria> orExpression =newArrayList<>();for(Map<String,Object> accounts : attributes){Criteria expression =newCriteria();
accounts.forEach((key, value)-> expression.and(key).is(value));
orExpression.add(expression);}
orQuery.addCriteria(orCriteria.orOperator(orExpression.toArray(newCriteria[orExpression.size()])));List<User> userList = mongoOperations.find(orQuery,User.class);
上一篇: 大侠与老板的终极PK
下一篇: 好笑逗人的的童言童语