Issue
I am using spring-boot and hibernate. I have the following table:
firstName | lastName | department(FK) | city
So far, I was successful in finding records by department (FK) with the following in my repository:
List<User> findByDepartmentId(@Param(value = "department") Long department);
Now, I would like to find not only by department, but also by city (which is a string value). How can I do that?
Solution
You can use And
in your method name (assuming you are using spring-data-jpa
and city
is the name of the field in your model),
List<User> findByDepartmentIdAndCity(Long id, String city);
Answered By - techtabu