Reputation: 3715
I m using Spring Data Rest JPA which implements the Query internally on the basis of method name.
I wrote the following method in my repository interface which should list all the users in a state and if the name and/or age is present, it should filter the result.
StateId is mandatory but name and age are optional filter parameters
public List<User> findByStateIdAndNameOrAge(Integer stateId, String name , Integer age, Pageable pageable);
I am not getting any results. Where am I doing wrong?
Upvotes: 5
Views: 5365
Reputation: 1100
You can try
There is no mistake in your method defination.
public List<User> findByStateIdAndNameOrAge(Integer stateId, String name , Integer age, Pageable pageable);
but you can't pass null parameter to this method so it will not work if you are putting any parameter is blank.
Upvotes: 1