#261 iterate mapping with more than one hint fails

Dozer v5.3.3
closed-fixed
7
2011-10-09
2010-05-27
Anonymous
No

We have an object structure with a parent and a list of children. The child objects are of different type but all implement the same interface. Assume the following mapping:

<mapping>
<class-a>ParentDto</class-a>
<class-b>Parent</class-b>
<field>
<a>children</a>
<b set-method="addChild" type="iterate">children</b>
<a-hint>
ChildADto,
ChildBDto
</a-hint>
<b-hint>
ChildA,
ChildB
</b-hint>
</field>
</mapping>

The mapping fails because MappingProcessor assumes that only one destination hint is present. This seems to be an unnecessary restriction. The following patch fixes the issue in our case:

$ diff MappingProcessor.java MappingProcessor.java.patched
606c606
< value = map(value, fieldMapping.getDestHintContainer().getHint());
---
> value = map(value, fieldMapping.getDestHintType(value.getClass()));

please consider applying this patch to the dozer codebase.

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2010-06-03

    same issue reported here: "list with a hierarchy - hint problem - ID: 2794873"
    http://sourceforge.net/tracker/?func=detail&aid=2794873&group_id=133517&atid=727370;

     
  • jegese

    jegese - 2010-08-16

    I have a unit test for learning how "iterate" works with other attributes like remove orphan, cumulative, and hints. Actually, none of the combination of these attributes works if I use iterate.

    For the hint attribute the solution would be to review the usages of the method:

    org.dozer.fieldmap.HintContainer.getHint()

    and replace them where needed as the posts wrote.

    I couldn't attach the unit test to this issue, how could I do that without opening a new issue?

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2011-09-20
    • priority: 5 --> 7
     
  • dmitry (lv)

    dmitry (lv) - 2011-10-09

    fixed in trunk

     
  • dmitry (lv)

    dmitry (lv) - 2011-10-09
    • milestone: 1049123 --> Dozer v5.3.3
    • assigned_to: nobody --> buzdin
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks