Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#300 ClassMappings get wrong ClassMap in polymorphism case

Dozer v5.3.2
closed-fixed
nobody
5
2010-12-19
2010-12-13
Joan DAVID
No

I have an issue in the following case:

class A {
private String prop1:
private String prop2;
// geters/setters
}

class B {
private String prop1:
// geters/setters
}

class C extends B{
private String prop2;
// geters/setters
}

if I map A->C ClassMappings store a ClassMap<A,C> then I try to map A -> B and ClassMappings give me the previous ClassMap<A,C> so I have an exception like :
org.dozer.MappingException: No read or write method found for field (prop2) in class (class B)

the bug is caused by the cose in "findInterfaceMapping" method
ex : if (destClass.isAssignableFrom(mappingDestClass) ||
(mappingDestClass.isInterface() && mappingDestClass.isAssignableFrom(destClass))) {
So has B.isAssignableFrom(C) => true ClassMap<A,C> is ok for the couple A,B

For resolving it I just comment the "findInterfaceMapping" method and it's call in "find" method.

Discussion

  • dmitry (lv)
    dmitry (lv)
    2010-12-19

    fixed in 5.3.2. This was a feature for abstract type mappings. Now if() conditions are also checking if type is abstract or not.

     
  • dmitry (lv)
    dmitry (lv)
    2010-12-19

    • milestone: 1323099 --> Dozer v5.3.2
    • status: open --> closed-fixed