So... Is there a way to do something like this?
class Kitty {
String name
String nickName
public static String getExpectedNickname(String name) {
return name.replaceAll('Mr. ', '')
}
static namedQueries = {
byKityWithPredictableNickname {
ilike 'name', '%Kitty%'
ilike 'nickName', Kitty.getExpectedNickname('name')
}
}
}
Can I reference the value of the current row's column value somehow? I thought property('name') would work, but alas, no.
EDIT:
Another example: I thought something like this would work... but it doesn't :( ...
static namedQueries = {
whyDoesntThisReturnEverything {
int c = Kitty.bySubQuery(id).count() //returns everything when I put "1" instead of "id"
c == 1
}
bySubQuery { Long paramId ->
eq 'id', paramId
}
}
Instead I get some stupid illegal argument exception:
java.lang.ClassCastException@2af65a43. Stacktrace follows:
Message: java.lang.ClassCastException@2af65a43
Line | Method
->> -1 | invoke in sun.reflect.GeneratedMethodAccessor327
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 43 | invoke in sun.reflect.DelegatingMethodAccessorImpl
| 606 | invoke . . . . . . . . . . . . . . . in java.lang.reflect.Method
| 1254 | jlrMethodInvoke in org.springsource.loaded.ri.ReflectiveInterceptor
| 90 | invoke . . . . . . . . . . . . . . . in org.codehaus.groovy.reflection.CachedMethod
| 57 | getProperty in groovy.lang.MetaBeanProperty
...