Consider the following table:
table: people_info
|| row || name || surname || nationality || time_do_coracao
| 1 | marcelo | aragao | brasil | sp
| 2 | maria | fonseca | brasil | sp
| 3 | joao | timotio | brasil | palmeiras
| 4 | marcelo | vasconcelos | brazil | corinthians
Imagine that I have a form with all these fields, where none of them is required. I need to take into account only the fields entered by the user, so if the user populates the field nationality = brazil and tipe_do_coracao = sp, the application should bring lines 1 and 2.
In my jpa application I did the following:
em.createNativeQuery ("select nome from info_pessoas where nome = ? and sobrenome = ? and nacionalidade = ? and time_do_coracao = ?")
obs: the "?" will be filled with the values entered by the user, in this case the 3 and 4 "?" were filled with Brazil and sp respectively.
The problem is that no line is being returned, what is the right way to mount the query?