grails - How to do a 'where' query on a GORM object with matching local variable names -


let's wish search grails domain object, , parameter values in local variables names match object's attribute names:

def getperson(string firstname, string lastname) {     person person = person.where {         firstname == firstname         lastname == lastname     } } 

how can query written find person attributes match local variable values?

i believe can use implicit delegate variable follows:

def getperson(string firstname, string lastname) {     person person = person.where {         delegate.firstname == firstname         delegate.lastname == lastname     } } 

edit: isn't necessary according spec / test case, find explicit use of delegate easier read/understand.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -