I am starting to use named queries, and am not sure how to handle one thing. I have a query like "from myTable". If the user passes in a firstName, or lastName, or Date of birth, the query should be however, at runtime, I am not sure if the user is going to pass any or all of the parameters.
I want to have this query defined in my file NamedQuery.hbm.xml
I just don't know how to handle deciding on the fly if I need to remove one of the things like lname = :lastName from my query.
Can I do something like this in the code (use a wildcard)
I've never used named queries myself but my first guess is if you want to use a wildcard you should probably try the SQL-wildcard of your DBMS. That is, most likely, the per-cent sign "%".
Joined: May 17, 2001
Thank you very much, yes, using the "%" did the trick.
It however brought me to a new problem, one of the fields I am trying to compare is a date, so if I have this in my query:
as part of my query, and my DOB value is null so I do this :
I then get the follwing error :