#170 Inheritance + Map-Id

Dozer v5.0
closed
5
2014-08-19
2009-02-11
2#4u
No

When mapping 2 independent class hierarchies by using
- top-level class types as destination mapping types AND
- using a map-id as "hierarchy-identifier"
dozer is only able to map in one direction.

Although i don't know if i am using dozer in the way it was designed for, this is still a bug.

I solved the issue for myself by editing net.sf.dozer.util.mapping.util.ClassMapFinder:

BEFORE:

...
57: ClassMap classMap = null;
while (iter.hasNext()) {
Map.Entry entry = (Entry) iter.next();
classMap = (ClassMap) entry.getValue();
if (StringUtils.equals(classMap.getMapId(), mapId)) {
return classMap;
}
}
log.info("No ClassMap found for mapId:" + mapId);
...

AFTER:

...
57: ClassMap classMap = null;
ClassMap anySuitableMap = null;
while (iter.hasNext()) {
Map.Entry entry = (Entry) iter.next();
classMap = (ClassMap) entry.getValue();
if (StringUtils.equals(classMap.getMapId(), mapId)) { // this is not enough, there are probably two maps with this id
anySuitableMap = classMap;
// check the direction of the mapping
if (srcClass.equals(classMap.getSrcClassToMap())) {
return classMap;
}
}
}
if (anySuitableMap != null) return anySuitableMap;
log.info("No ClassMap found for mapId:" + mapId);
...

see the attached file for more information.

Discussion

  • 2#4u

    2#4u - 2009-02-11

    Junit Test Case without lib-dependencies

     
  • Matt Tierney

    Matt Tierney - 2009-02-18
    • milestone: 897300 --> Dozer v5.0
    • assigned_to: nobody --> mhtierney
    • status: open --> closed
     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks