title: Mapping a collection of entities to a collection of their Ids
body: <p>I'm building a RESTful service an I am using Dozer to map my entities retrieved by JPA/Hibernate to DTO and vice versa. Let's assume the following scenario. I have the classes EntityA and EntityB as well a my EntityADto as DTO.</p>
  
  <pre><code>@Entity
  public class EntityA {
      @GeneratedValue
      @Id
      private Integer id;
      private EntityB entityB;
  
      /* Getter &amp; Setter */
  }
  
  @Entity
  public class EntityB {
      @GeneratedValue
      @Id
      private Integer id;
  
      /* Getter &amp; Setter */
  }
  
  public class EntityADto {
      private Integer id;
      private Integer entityBId;
  
      /* Getter &amp; Setter */
  }
  </code></pre>
  
  <p>In this case I can map the entityB of type EntityB to my Integer entityBId by the following mapping:</p>
  
  <pre><code>&lt;mapping&gt;
    &lt;class-a&gt;EntityA&lt;/class-a&gt;
    &lt;class-b&gt;EntityADto&lt;/class-b&gt;
      &lt;field&gt;
        &lt;a&gt;entityB.id&lt;/a&gt;
        &lt;b&gt;entityBId&lt;/b&gt;
      &lt;/field&gt;
  &lt;/mapping&gt;
  </code></pre>
  
  <p>This works so far.</p>
  
  <p>But if I have a class EntityA with a Set of EntityB objects, I can't get it mapped to the ids.</p>
  
  <pre><code>@Entity
  public class EntityA {
      @GeneratedValue
      @Id
      private Integer id;
      private Set&lt;EntityB&gt; entityBs;
  
      /* Getter &amp; Setter */
  }
  
  public class EntityADto {
      private Integer id;
      private Set&lt;Integer&gt; entityBIds;
  
      /* Getter &amp; Setter */
  }
  </code></pre>
  
  <p>I'd rather avoid using a custom mapper and use XML configuration if possible.</p>