Note that there are some explanatory texts on larger screens.

plurals
  1. PODozer mapping inner classes
    primarykey
    data
    text
    <p>I need to map class A into class C using dozer framework.</p> <pre><code>public class A { private String fielda1; private String fielda2; public String getFielda1() { return fielda1; } public void setFielda1(String fielda1) { this.fielda1 = fielda1; } public String getFielda2() { return fielda2; } public void setFielda2(String fielda2) { this.fielda2 = fielda2; } } public class B { private List&lt;C&gt; cList; public List&lt;C&gt; getcList() { return cList; } public void setcList(List&lt;C&gt; cList) { this.cList = cList; } public static class C { private String fieldc1; private String fieldc2; public String getFieldc1() { return fieldc1; } public void setFieldc1(String fieldc1) { this.fieldc1 = fieldc1; } public String getFieldc2() { return fieldc2; } public void setFieldc2(String fieldc2) { this.fieldc2 = fieldc2; } } } </code></pre> <p>XML mapping file:</p> <pre><code>&lt;mapping wildcard="false" map-null="false" map-id="test"&gt; &lt;class-a&gt;test.A&lt;/class-a&gt; &lt;class-b&gt;test.B.C&lt;/class-b&gt; &lt;field&gt; &lt;a&gt;fielda1&lt;/a&gt; &lt;b&gt;fieldc1&lt;/b&gt; &lt;/field&gt; &lt;field&gt; &lt;a&gt;fielda1&lt;/a&gt; &lt;b&gt;fieldc2&lt;/b&gt; &lt;/field&gt; &lt;/mapping&gt; </code></pre> <p>When i try to map these classes i got following exception:</p> <pre><code>org.dozer.MappingException: java.lang.ClassNotFoundException: test.B.C at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:88) at org.dozer.util.DefaultClassLoader.loadClass(DefaultClassLoader.java:33) </code></pre> <p>It seams that dozer is not capable to handle this situation and uses class B as a package name. This issue can be resolved using custom converters. I just want to know is there any trick that could be used to convert these classes using just XML configuration ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload