#182 Hints doesn't work with inherited classes

Dozer v5.1
K. R.

Hi Guys.
I've recently updated my Dozer distribution from v4.3 to 5.0. And now, I'm facing strange problem with inherited classes.
We have class A and 4 derived classes:
1) B extends A
2) C extends A
3) D extends A
4) E extends A

Furthemore, we have a container class
class F{
int suka;
Set<A> ass;
As far as you understand, F.ass can contain any of the B,C,D,E typed objects.
Also, I have corresponding DTO classes, say:
1)Bdto extends Adto
2)Cdto extends Adto
3)Ddto extends Adto
4)Edto extends Adto
And class Fdto{
int suka;
Set<Adto> ass;

With Dozer 4.3 to convert F to Fdto I had such mapping:


It was working great, but since update to the v5.0 it doesn't work:
instead of Fdto.ass to be Set of the Bdto/Cdto/Ddto/Edto I always have it as Set of the Adto( parent) class.
How could it be fixed?


  • K. R.

    K. R. - 2009-03-27

    Guys, I've found the reason. It's critical bug in the Dozer!!!

    Prior to the version 5 in the method of the class

    private Object mapCollection(Object srcObj, Object srcCollectionValue, FieldMap fieldMap, Object destObj) {

    you had the following piece of code
    // since we are mapping some sort of collection now is a good time to decide
    // if they provided hints
    // if no hint is provided then we will check to see if we can use JDK 1.5
    // generics to determine the mapping type
    // this will only happen once on the dest hint. the next mapping will
    // already have the hint
    if (fieldMap.getDestHintContainer() == null && GlobalSettings.getInstance().isJava5()) {
    Class genericType = null;
    try {
    Method method = fieldMap.getDestFieldWriteMethod(destObj.getClass());
    genericType = ReflectionUtils.determineGenericsType(method, false);
    } catch (Throwable e) {
    log.info("The destObj:" + destObj + " does not have a write method");
    if (genericType != null) {
    HintContainer destHintContainer = new HintContainer();

    But now, in the version 5, the first line
    if (fieldMap.getDestHintContainer() == null) disappeared from this method, so this method always looks the generic class from the signature of the method to use as destination hint, despite any users setupped hints.

    Please, put this condition back ASAP.

  • K. R.

    K. R. - 2009-03-27
    • priority: 5 --> 9
  • dmitry (lv)

    dmitry (lv) - 2009-03-27
    • milestone: 888640 --> Dozer v5.1
    • priority: 9 --> 7
    • assigned_to: nobody --> buzdin
    • status: open --> closed-fixed
  • dmitry (lv)

    dmitry (lv) - 2009-03-27

    fixed in trunk


Log in to post a comment.

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

Sign up for the SourceForge newsletter:

No, thanks