Last active
December 12, 2022 10:48
-
-
Save thomasmartin-whoz/0dcf4b577c7d31e0ab6baa3312bc8118 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Repository | |
class PersonRepositoryImpl implements PersonRepositoryCustom { | |
@Autowired | |
MongoTemplate mongoTemplate | |
@Override | |
List<Person> findByIdsOrFirstNameOrLastName(List<String> personIds, String firstName, String lastName){ | |
Criteria allCriteria = [ | |
personIds?.with { Criteria.where('_id').in(it) }, | |
firstName?.with { Criteria.where('firstName').is(it) }, | |
lastName?.with { Criteria.where('lastName').is(it) }, | |
].findAll() | |
return mongoTemplate.find(Criteria().andOperator(allCriteria), Person.class) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment