#148 Mapping with remove-orphans changes the list order

Dozer v.4.3

To reproduce:
1. Setup a mapping of a field of type List to another List field
2. Select remove-orphans="true"
3. Add a few elements to the source list
4. Compare the order of the target list with the source list

MappingProcessor#addOrUpdateToList() puts the elements into the mappedElements HashSet. If the source list contains a few elements the hashCode() method reorders the elements in mappedElements. This makes the result order different than the source order.

See the attachment for a working example.

The fix is to change mappedElements to ArrayList.

It seems that MappingProcessor#addToSet() could use HashSet for its mappedElements instead of ArrayList. It looks like the types of mappedElements in addOrUpdateToList() and addToSet() are swapped.


  • Karol Bienkowski

    A working example: run RunMe with JUnit

  • dmitry (lv)

    dmitry (lv) - 2008-11-19


    You are completely right. I have changed both Set and List methods. Now original element ordering will be retained. If you have source "A,B,C" and destination "B,C,D" result will be "B,C,A" regardless of hashCode() values.

    Fix will be included in next release.

  • dmitry (lv)

    dmitry (lv) - 2008-11-19
    • labels: --> Mapping Issue
    • milestone: --> Dozer v.4.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