Suppose I have an Employee
class with multiple fields like name
, age
, salary
, designation
, joiningDate
, gender
and many more. Now, how could I apply filtering with many such parameters? There could be many combinations possible in such cases. (For Eg. if I want to have 6 filters, then there can be total of 6! = 720 combinations possible!!!)
For only 2, 3 parameters, like age
, salary
, name
; then I could write multiple if cases like:
if(age!=null && name==null && salary==null)
{
findByAge
}
if(age==null && name!=null && salary==null)
{
findByName
}
if(age!=null && name!=null && salary==null)
{
findByAgeAndName
}
etc. like these with help of Spring Data JPA. But how to handle more parameters since combinations would increase with each RequestParams?