Hi everyone:
There is a search function in my web application.I want to implement the function using hibernate. But the problem is that the query parameter is too much. There are 10 parameter in this site search function. So I think it has a problem. For example:
search according the following condition:
name: age: email: address: cell_phone:
home_phone: phone: country: ... ... etc...
If the client don't input any things my method will get a "null" value or a blank value. The function will not work property. But the fact is that if user don't input anything the condition will be all. I mean that if user don't input the name parameter,the function will query all name's data.
For example:
if the input info is this:
name: yashnoo. email:yashnoo@yahoo.com
the query will be :
Code:
from mytable where name=yashnoo and email=yashnoo@yahoo.com
if the input info is this:
name: (not input anything) email:yashnoo@yahoo.com
the query will be:
Code:
from mytable where email=yashnoo@yahoo.com
Not this:
Code:
from mytable where name=null and email=yashnoo@yahoo.com
The later will query nothing obviously.
Could hibernate has any query method that can ignore null value? THks