javaxmljaxbdozerjax-rpc

Dozer deep mapping not working


I am trying to use dozer 4.1 to map between classes. I have a source class that looks like this:

    public class initRequest{
     protected String id;
     protected String[] details
}

I have a destination class that looks like this:

public class initResponse{
       protected String id;
       protected DetailsObject detObj;
}

public class DetailsObject{
 protected List<String>  details;
}

So essentially i want the string in the details array to be populated into the List in the Details object.

I have tried a mapping like this:

<mapping wildcard="true" >
  <class-a>initRequest</class-a>
  <class-b>initResponse</class-b>   
  <field>
    <a is-accessible="true">details</a>
    <b is-accessible="true">detObj.details</b>
  </field>
</mapping>

But I get this error:

Exception in thread "main" net.sf.dozer.util.mapping.MappingException: java.lang.NoSuchFieldException: detObj.details
    at net.sf.dozer.util.mapping.util.MappingUtils.throwMappingException(MappingUtils.java:91)
    at net.sf.dozer.util.mapping.propertydescriptor.FieldPropertyDescriptor.<init>(FieldPropertyDescriptor.java:43)
    at net.sf.dozer.util.mapping.propertydescriptor.PropertyDescriptorFactory.getPropertyDescriptor(PropertyDescriptorFactory.java:53)
    at net.sf.dozer.util.mapping.fieldmap.FieldMap.getDestPropertyDescriptor(FieldMap.java:370)
    at net.sf.dozer.util.mapping.fieldmap.FieldMap.getDestFieldType(FieldMap.java:103)
    at net.sf.dozer.util.mapping.util.MappingsParser.processMappings(MappingsParser.java:95)
    at net.sf.dozer.util.mapping.util.CustomMappingsLoader.load(CustomMappingsLoader.java:77)
    at net.sf.dozer.util.mapping.DozerBeanMapper.loadCustomMappings(DozerBeanMapper.java:149)
    at net.sf.dozer.util.mapping.DozerBeanMapper.getMappingProcessor(DozerBeanMapper.java:132)
    at net.sf.dozer.util.mapping.DozerBeanMapper.map(DozerBeanMapper.java:94)

How can i map this so that it works?


Solution

  • Problem solved...

    Combining the two is a feature that does not work in Dozer (maybe it does in a newer version)

    solution... modify the xsd such that the deep mapping is not required. This is not my ideal solution but its better than writing a custom converter for every object