Can parameters be used when defining a where query in Grails 2.0? For instance:
def query = Book.where { id == it } Book sub = query.find(5)
I tried running this code, but it throws a MissingMethodException to find. I also tried to define the variable in front of it, but it does not work (since find returns null, although I know that it exists).
Long someId = 5 def query = Book.where { id == someId } Book sub = query.find()
Any tricks? The ability to dynamically change query parameters will be extremely useful.
(I know I can just use Book.get (5), but for simplicity, it looked like the simplest example)
source share