How can I make a dynamic Grails search? -


consider domain class:

class house {   integer room   integer bathroom   date builtdate   date boughtdate    string roadname    string getsearch(){     return room + " " + bathroom + " " + builtdate + " " + boughtdate   } } 

i imagine having several fields search mechanism: search room, bathroom, builtdate, boughtdate.

the user should able search combination of these paramaters. can use one, or of them. need controller code. i'm sure cannot using hql dynamic finders i'll have use sqls statments.

any help/hint appreciated.

you want use hibernate criteria. along lines of:

if (room && bathroom && builtdate && boughtdate) {   house.withcriteria {     if (room) {       gte 'room', room     }     // ...   } } 

look @ docs on createcriteria , withcriteria more information.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -