I have fixed this for the 1.5.6 release. We were checking for class type to class type. We never checked for interface or super types (i.e. isAssignable()).
Still have to be careful with the use of this. You could have a problem where you have some really generic base interface or super class. You could then accidentally have things mapped you were not expecting.
Thanks.
Franz
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm resuscitating this thread because we have a problem I think fits here.
To simplify let's say we have a class hierarchy with an abstract superclass S and subclasses A and B.
We also have a mirroring hierarchy SPrime, APrime and BPrime.
We want to use dozer to convert an instance of S to an instance of SPrime. Each class has its own mapping, with common properties mapped in the S->SPrime mapping file, and A->APrime and B->BPrime containing only their own mappings.
So we try to call mapper.map(s, SPrime.class), but we get InstantiationException because Dozer tries to instantiate SPrime, which is abstract.
Reading this thread, we expected Dozer to instantiate either APrime or BPrime depending on the actual runtime class of s, which obviously is not the case.
Is there anything we are missing? Does the polymorphic mapping only apply to properties, not root objects?
Any help appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Matthias,
I should have some time this weekend or earlier to look at this.
thanks,
Ben
I have fixed this for the 1.5.6 release. We were checking for class type to class type. We never checked for interface or super types (i.e. isAssignable()).
Still have to be careful with the use of this. You could have a problem where you have some really generic base interface or super class. You could then accidentally have things mapped you were not expecting.
Thanks.
Franz
BTW - I opened this as bug 1342127
Hello Franz,
my Problem is now fixed with 1.5.6.
Thanks Matthias
Hi there,
I'm resuscitating this thread because we have a problem I think fits here.
To simplify let's say we have a class hierarchy with an abstract superclass S and subclasses A and B.
We also have a mirroring hierarchy SPrime, APrime and BPrime.
We want to use dozer to convert an instance of S to an instance of SPrime. Each class has its own mapping, with common properties mapped in the S->SPrime mapping file, and A->APrime and B->BPrime containing only their own mappings.
So we try to call mapper.map(s, SPrime.class), but we get InstantiationException because Dozer tries to instantiate SPrime, which is abstract.
Reading this thread, we expected Dozer to instantiate either APrime or BPrime depending on the actual runtime class of s, which obviously is not the case.
Is there anything we are missing? Does the polymorphic mapping only apply to properties, not root objects?
Any help appreciated.
This used to work in 4.0 but has since been broken. I submitted a patch to fix this. see patch
: http://sourceforge.net/tracker/?func=detail&aid=2906090&group_id=133517&atid=727370
Sorry my ignorance, but I have the same problem and not know what to do, I'm using dozer 4.2 How do I apply the patch to the jar?
thanks