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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With