title: JAXB annotations for groovy attribute classes
body: <p>have a project set up like the following:</p>
  
  <pre><code>import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlAttribute;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.XmlSeeAlso;
  
  @XmlRootElement(name="employee")
  @XmlSeeAlso([EmployeeDesiredSkill.class, EmployeeDesiredTool.class,  EmployeeAreaOfExpertise.class, Project.class, Education.class])
  @XmlAccessorType(XmlAccessType.NONE)
  class Employee implements Comparable
  {       
  static hasMany = [employeeDesiredSkills:EmployeeDesiredSkill]     
   @XmlElement
       String name
      @XmlElement
      List&lt;EmployeeDesiredSkill&gt; employeeDesiredSkills = new ArrayList&lt;EmployeeDesiredSkill&gt;();
  }
  
  
  import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlAttribute;
  import javax.xml.bind.annotation.XmlElement;
  
  @XmlAccessorType(XmlAccessType.NONE)
  class EmployeeDesiredSkill implements Comparable
  {
  
  boolean _deleted
  @XmlElement
  Skill skill
  static belongsTo = [employee:Employee, skill:Skill]
  }
  
  import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlAttribute;
  import javax.xml.bind.annotation.XmlElement;
  
  @XmlAccessorType(XmlAccessType.FIELD)
  class Skill implements Comparable
  {
      static hasMany = [roleSkills:RoleSkill, employeeDesiredSkills:EmployeeDesiredSkill]
  
      boolean _deleted
  static transients = ['_deleted']
      @XmlAttribute
      String name
  }
  </code></pre>
  
  <p>When I try to do the XML marshaling of this setup, I get valid values foe Employee, but all of the skills come back empty, like so:</p>
  
  <pre><code>&lt;employee name = "Joe"&gt;
  &lt;employeeDesiredSkills&gt;
      &lt;skill name=""&gt;
          &lt;_deleted&gt;false&lt;/_deleted&gt;
      &lt;/skill&gt;
  &lt;/employeeDesiredSkills&gt;
  &lt;employeeDesiredSkills&gt;
      &lt;skill name=""&gt;
          &lt;_deleted&gt;false&lt;/_deleted&gt;
      &lt;/skill&gt;
  &lt;/employeeDesiredSkills&gt;
  &lt;employeeDesiredSkills&gt;
      &lt;skill name=""&gt;
          &lt;_deleted&gt;false&lt;/_deleted&gt;
      &lt;/skill&gt;
  &lt;/employeeDesiredSkills&gt;
  &lt;employeeDesiredSkills&gt;
      &lt;skill name=""&gt;
          &lt;_deleted&gt;false&lt;/_deleted&gt;
      &lt;/skill&gt;
  &lt;/employeeDesiredSkills&gt;
  &lt;employeeDesiredSkills&gt;
      &lt;skill name=""&gt;
          &lt;_deleted&gt;false&lt;/_deleted&gt;
      &lt;/skill&gt;
  &lt;/employeeDesiredSkills&gt;
  </code></pre>
  
  <p></p>
  
  <p>In other words - name is never returned from the Skill objects. I think Employee must know how many employeeDesiredSkills are in the list (since 5 of them show up), but for some reason can not get the values in the Skill class.</p>
  
  <p>What can I do to fix this? In my controller, if I do the following:</p>
  
  <pre><code>            def employee = Employee.get(session.empid);
              for(esd in employee.getEmployeeDesiredSkills()){println "EmployeeDesiredSkill:" + esd}
  </code></pre>
  
  <p>I get the full list of desired skills printed (5 of them), so I know the values are in the database already.</p>
  
  <p>To me it seems like the EmployeeDesiredSkill class doesnt know which employee to return the skills for, but I am not sure if that is the right thinking or not. I dont really want to add a belongsTo = Employee to my Skills class, because I want those skills to possibly be used by other employees as well. </p>