Java Spring Boot : How to find all rows with multiple Ids like findAllByAge(ArrayList<Long> ageList)?

Viewed 1267

I am having a table/entity User with fields like userId, name, age etc.

I know with Spring boot, in Repository, we can search for rows like

User findByUserId(Long userId)

Which may return User with the passed argument user id.

But I am looking for an option where I can pass a list in argument something like below.

List<User> findAllByAge(ArrayList<Long> ageList)

Which may return all the users with passed ageList. Let me know if this is possible with this or I have to use native query? I know I can do this with native queries also but if it's possible with this then it would be great.

1 Answers
Related