Is it possible to write a select
query with optional parameters?
Example: basically I want to fetch using the following query:
SELECT p from Person p where p.firstname = :firstname and p.lastname = :lastname;
But if this does not return a result, I want to query only by lastname.
Is that possible in a single query? Or should I execute an additional query within an open transaction?