Search code examples
javadozer

Dozer: map single field to Set


How do you map a single field into a Set in Dozer?

I have a class like:

class FooDTO {
    private IdDto bar;
    private IdDto baz;
}

class FooDomainObject {
    private List<Id> ids;
}

I'd like to map bar and baz into the ids list, but I can't get it to do this.


Solution

  • I found this on the Dozer support list:

     http://sourceforge.net/projects/dozer/forums/forum/452530/topic/1557144
    

    Basically, you use this syntax:

           <field>
                <a>bar</a>
                <b>ids[0]</b>
                <b-hint>org.foo.Id</b-hint>
            </field>
           <field>
                <a>baz</a>
                <b>ids[1]</b>
                <b-hint>org.foo.Id</b-hint>
            </field>