动态查询同个属性

阅读更多
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);

你可能感兴趣的:(mongo,动态)