Partheban Udayakumar wrote:I took a look over the links you provided but both of them deal with passing different values to same parameter (from what I understood, correct me if I am wrong), (ie) passing San Fransisco, New york, Chicago etc. to the city parameter but what I want is I have to build a criteria like "SELECT * FROM profile where name=? and fullName=? and title=? and city=? and state=? and country=?". Here as for any search the possibilities are only one parameter will be passed or all 6 may be passed. It has to search and bring back the result.
You are too much focused on what they do instead of looking more to how it's done. It is all about the concepts used in these articles.
Using the Specification API you could create different simple methods like
isName,
isFullName,
isTitle, and so on. And then you can freely combine atomic
Specifications to create new ones one on the fly. So if you combine them using a helper class with
and() and
or() methods, you can combine as many atomic methods as you want and build dynamic search queries.
Hope it helps!
Kind regards,
Roel