Bulldozer: get the first value in the collection displayed by one value at the destination

I map two DTO objects through the Maper Dozer. I am interested in choosing one value from the list and matching it with one field in the target file.

Is it possible to use a mapping as follows:

<field> <a>someList[0]</a> <b>someVariable</b> </field> 

It seems that part b may be of type list[1].value , but I cannot get it to work when the brackets are on side a . Where am I doing this wrong?

+4
source share
2 answers

In fact, you do not need more than what is offered

 <field> <a>someList[0]</a> <b>someVariable</b> </field> 

to achieve this goal. I had another problem: I did not call the correct map() function for this mapping in my code. I had several mappings and there was no map() call for this particular one.

+3
source

Use the following mapping:

 <mapping map-id="collectionMapping" type="one-way"> <class-a>java.util.Collection</class-a> <class-b>java.util.Collection</class-b> <field> <a>this</a> <b set-method="add(java.lang.Object)" type="iterate">anything</b> <b-hint>your destination object type</b-hint> </field> </mapping> 
+1
source

All Articles