Menu

#32 list with a hierarchy - hint problem

open
nobody
None
5
2009-05-21
2009-05-21
No

I tied to map a list with a hierarchy and I find 2 problems.

<mapping>
<class-a>CLASSA</class-a>
<class-b>CLASSB</class-b>
<field relationship-type="non-cumulative">
<a>listA</a>
<b set-method= "addInListB" type="iterate">listB </b>
<a-hint> classX, classY, classZ </a-hind>
<b-hint> classS, classT, classU </b-hint>
</field>
</mapping>

First problem was that if I tried to add more than 1 hint, dozer threw a NullPointerException because fieldMapping.getDestHintContainer().getHint() returns null in case of more hints than 1. Instead of this I introduced in mapFromIterateMethodFieldMap method: fieldMapping.getDestHintType(value.getClass())

The second problem when I tried to map a hierarchy with a base object, dozer tried to map everything to the base object even in the xml there was the list of hints of destination.
The problem was in mapCollection method because in case of a generic type dozer update the DestHintContainer even it is set with the custom mapping xml.
Before update this hint list, I tested it if it is needed or not.

if (fieldMap.getDestHintContainer() == null) {
fieldMap.setDestHintContainer(destHintContainer);
}

Discussion

  • Adonia Antal

    Adonia Antal - 2009-05-21

    hint problem in case of list with a hierarchy

     
  • luk

    luk - 2009-10-23

    Same "bug" and solution found:

    line 588 in MappingProcessor (@958), change from
    value = map(value, fieldMapping.getDestHintContainer().getHint());
    to
    value = map(value, fieldMapping.getDestHintType(value.getClass()));

    Would be nice to have this in trunk.
    Thanks in advance.

     
  • Anonymous

    Anonymous - 2010-09-09

    Same "bug". I'm using version 5.2.2

    Don't you need a remove-method param?

     
  • jegese

    jegese - 2010-09-10

    Actually there are several other calls to getDestHintContainer().getHint(). All should be eliminated.

    Check this bug report:
    http://sourceforge.net/tracker/?func=detail&aid=3008059&group_id=133517&atid=727368

    It is about the same problem, I have created a unit test for this, but there is no answer to it yet. It might be that the problem is more complex than we think.

     

Log in to post a comment.