I am able to search for a keyword in a column using
List<Application> findByProposalContainingIgnoreCase(String keyword);
How can I achieve the same using a list of keywords?
For example:
List<Application> findByProposalContainingIgnoreCase(List<String> keywords);
UPDATE:
If it is not possible to do so, is the below way effective:
@Autowired
private ApplicationService applicationService;
List<Application> applications = new ArrayList<>();
for (String keyword : keywords) {
applications.addAll(applicationService.findByProposalContainingIgnoreCase(keyword));
}
It's not possible as normal sql cannot do it either. The use of the word 'like' implies searching for all the possibilities that contain the keyword provided. In your case you'd have to string multiple contains statements together like
List<Application> findByProposalContainingIgnoreCaseOrProposalContainingIgnoreCase(String keyword1, String keyword2);
You might be better of doing the in
keyword for your list
List<Application> findByProposalIn(Set<String> proposals);
The problem arises though that now you would have to add both uppercase and lowercase of the proposal to the set as it might not be case sensitive, and it will look for the exact matches not part of the word. Its not ideal but I think it'll work for what you're trying to do.
UPDATE
You're answer by adding the for loop would suffice for what you need.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.