domain relationships in shell / console
Hi,
I'm trying to investigate the properties of relationships between domain objects, using the groovy console or shell. I can't get it to load the associations though.
/* trimmed down to remove irrelevant fields and methods */
class Customer {
String name
Set sites
static hasMany = [ sites : Site ]
}
$ grails shell
[...]
groovy:000> c = Customer.get(1)
===> Customer One
groovy:000> c.sites
[92288] hibernate.LazyInitializationException failed to lazily initialize a collection of role: Customer.sites, no session or session was closed
[snip massive stack trace]
I think I understand what's happening, but I need some code for the console that says "execute the following block in the context of a valid Hibernate session".
Thanks
Jon