title: How to reference a Grails domain class fields from outside of the Grails controller and view?
body: <p>I have the domain classes:</p>
  
  <pre><code>class Child {
      static hasMany = [ toys : Toy ]
      String name
      Set  toys
  }
  class Toy {
      static belongsTo = [ owner : Child ]
      String name
  }
  </code></pre>
  
  <p>In my JSP I reference a child by:</p>
  
  <pre><code>child = Child.findByName("Joe")
  </code></pre>
  
  <p>or</p>
  
  <pre><code>child = Child.findById(123)
  </code></pre>
  
  <p>But when I attempt to access its fields:</p>
  
  <pre><code>child.getToys()
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: Child.toys, no session or session was closed
  </code></pre>
  
  <p>Do I need to manually start the Hibernate session? If so how would I do this?</p>
  
  <p><strong>Follow-up Feb 2012</strong>: This behavior is also present when running from the Grails console (Grails 2.0.0)</p>