I have an GET endpoint which fetches the data based on the below parameters. firstName is mandatory and rest all are optional.
{
"firstName:"",
"lastName:"",
"Gender:"",
"city"""
}
How should i approach for the database query? i am using Sring Data JPA, I have tried
findByFirstNameOrLastNameOrGenderOrCity(firstName,lastName,Gender,City)
Not sure if a native sql query using @Query annotation will work as any of the values apart from firstName can be null if the consumer of the endpoint is not sending the values. Kindly help
If you need something like this:
then you can use like this query: