Grails domain class initialization
Posted
by Don
on Stack Overflow
See other posts from Stack Overflow
or by Don
Published on 2010-05-11T10:07:30Z
Indexed on
2010/05/11
13:44 UTC
Read the original article
Hit count: 283
Hi,
My Grails app has the following Spring bean defined in spring/resources.groovy
calendarService(CalendarService) { bean ->
bean.initMethod = "init"
}
This method looks something like:
class CalendarService {
void init() {
User.findByEmail("[email protected]")
}
}
When I call the dynamic finder findByEmail
I get a MissingMethodException
. My guess is that I'm trying to call this method too early, i.e. before the domain classes have had the dynamic finders added to their metaclass. One solution would be to call CalendarService.init()
myself from Bootstrap.init
, rather than instructing Spring to call it, but is there a better solution?
Thanks, Don
© Stack Overflow or respective owner