title: How can I use embedded GORM classes in Grails?
body: <p>Following the <a href="http://grails.org/doc/2.2.0/guide/GORM.html#gormComposition" rel="nofollow">GORM docs</a> I tried to use the following domain class with Grails 2.2.1:</p>
  
  <pre><code>package grailscompositiontest
  
  class ScafPerson {
      String name
      ScafAddress homeAddress
      ScafAddress workAddress
  
      static constraints = {
          name(nullable: false, blank: false)
      }
  
      static embedded = ['homeAddress', 'workAddress']
  }
  
  class ScafAddress {
      String number
      String code
  }
  </code></pre>
  
  <p>The controller just uses scaffolding:</p>
  
  <pre><code>package grailscompositiontest
  
  class ScafPersonController {
      static scaffold = true
  }
  </code></pre>
  
  <p>Unfortunately this does not work, it triggers a server error as soon as I browse to the "create" view:</p>
  
  <pre><code>URI:     /GrailsCompositionTest/scafPerson/create
  Class:   java.lang.NullPointerException
  Message: Cannot get property 'id' on null object
  </code></pre>
  
  <p>Any idea what I am doing wrong?</p>