Menu

#101 Mapping from interface/abstract class to well-known concrete

open
None
5
2007-08-21
2007-07-16
jcsf
No

Hi there,

Although I appreciate that mapping from a concrete to an interface/abstract class is something of a pipedream, I do feel that mapping from an interface/abstract to a well-known concrete should be achievable.

Attached is a simple test case. It throws a MappingException when I feel it should just do the mapping.

Inner is a simple class which has a single member "string" (along with accessors).

Outer holds a reference to an Inner "inner". This field has a static/compile type of Object - but a runtime time of "Inner".

My mapping configuration tries to map what in essence is ((Inner) outer.getInner()).getString() to a well-known target type of "Target".

MappingException is thrown because from a purely static/reflective point of view (i.e. not taking into consideration any runtime types), the member "inner" is of type Object - and not of type Inner.

When we're moving from complex object graphs (the "enterprise language") to a more specific domain graph, we often need to do deep field mappings from an interface/abstract member to a well-known type.

I have been selling Dozer hard as we use it on another project. Unfortunately, I have to give a demo on Wednesday, and it doesn't work for this example! I will have to try and fudge a workaround in for now :)

Thanks
JC

Discussion

  • jcsf

    jcsf - 2007-07-16

    test classes, dozer config + test case

     
  • Matt Tierney

    Matt Tierney - 2007-08-21
    • assigned_to: nobody --> mhtierney
     

Log in to post a comment.

MongoDB Logo MongoDB