#185 Hard to use XML config when mapping from/to java.util.Map

Dozer v5.3.0
closed-fixed
5
2010-09-03
2009-04-01
No

When using XML file to configure dozer to map between two {@link java.util.Map}s, there's no neutral configuration file.
The observed problem is as follows - when mapping without an XML file - it's OK, creating an XML file and providing <mapping> for this class but with no specific options make the mapping fail.

I thought:
<mapping>
<class-a>SomeClass</class-a>
<class-b>SomeClass</class-b>
<field>
<a>values</a>
<b>values</b>
</field>
</mapping>
is neutral to the mapping configuration and running with and without such an element should give the same results.
It doesn't if values is of type java.util.Map.

Sorry for a chaotic description, please take a look at the attached file. There's a working example (for both versions 4.2 and 5.0).

Discussion

  • GrzegorzOledzki

    GrzegorzOledzki - 2009-05-08

    For us the workaround was to change:

    if (MappingUtils.isSupportedMap(classMap.getDestClassToMap())
    || MappingUtils.isSupportedMap(classMap.getSrcClassToMap())
    || MappingUtils.isSupportedMap(fieldMap.getDestFieldType(classMap.getDestClassToMap()))
    || MappingUtils.isSupportedMap(fieldMap.getSrcFieldType(classMap.getSrcClassToMap()))) {

    to

    if (MappingUtils.isSupportedMap(classMap.getDestClassToMap())
    || MappingUtils.isSupportedMap(classMap.getSrcClassToMap())) {

    to prevent MapFieldMap being used when mapping two java.util.Maps. I am not really sure if it's inline with all the use cases, so I don't submit it as a patch.
    I only guess there's nothing special about mapping two maps, a generic FieldMap is enough. Mapping map's elements is a different story and a special FieldMap subclass (MapFieldMap) comes in handy.

     
  • dmitry (lv)

    dmitry (lv) - 2010-09-03
    • milestone: 888640 --> Dozer v5.3.0
    • assigned_to: nobody --> buzdin
    • status: open --> closed-fixed
     
  • dmitry (lv)

    dmitry (lv) - 2010-09-03

    Did it in a slightly different fashion:

    (isSupportedMap(classMap.getDestClassToMap())
    && !isSupportedMap(classMap.getSrcClassToMap()))
    || (isSupportedMap(classMap.getSrcClassToMap())
    && !isSupportedMap(classMap.getDestClassToMap()))
    || (isSupportedMap(fieldMap.getDestFieldType(classMap.getDestClassToMap()))
    && !isSupportedMap(fieldMap.getSrcFieldType(classMap.getSrcClassToMap())))
    || (isSupportedMap(fieldMap.getSrcFieldType(classMap.getSrcClassToMap())))
    && !isSupportedMap(fieldMap.getDestFieldType(classMap.getDestClassToMap())

    But the idea is the same.

     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks