Say I have a Record entity with 3 fields a, b and c, and given a Record instance rec, I use r's fields as criteria for a predefined (named) SELECT query (with AND on all fields).
Does JPQL allow us to write a query that can do wildcard matches on fields that are null?
eg. if rec has all 3 of a, b and c set, then the query would simply be:
But if say field c is null, I'd like to do something like this:
Which should work effectively as this JPQL query:
I want to do wildcard matches because there are quite a number of fields in my entity, and I don't know in advance how many of them (and in which combination) will be supplied in the search criteria. And I'd like to do the above as a named query if possible to avoid having to dynamically construct SQL by hand.