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);
动态查询同个属性
最新推荐文章于 2020-02-12 12:47:10 发布