I'm getting a java.lang.IllegalArgumentException: Result Maps collection already contains value for" error when trying to do some XML mappings on a nested class:
I have the following nested classes structure:
package com.test;
public class ObjectA {
private List<ObjectB> entries;
public ObjectA(List<ObjectB> entries) {
this.entries = entries;
}
public void setEntries(List<ObjectB> entries) {
this.entries = entries;
}
public List<ObjectB> getEntries() {
return this.entries;
}
public class ObjectB {
private String param1;
public ObjectB(String param1) {
this.param1 = param1;
}
public void setParam1(String param1) {
this.param1 = param1;
}
public String getParam1() {
return this.param1;
}
}
}
And the xml mappers look like this:
<resultMap id="ObjectA" type="com.test.ObjectA">
<collection property="entries" resultMap="Entries"/>
</resultMap>
<resultMap id="Entries" type="com.test.ObjectA.ObjectB">
<result property="param1" column="column1"/>
</resultMap>
If i take the ObjectB class outside of ObjectA class, the mapping works fine. But the thing is that i don't want to do that. I want to have it nested.
Thanks
I see two problems here:
$
and not .
. So instead of com.test.ObjectA.ObjectB
your path should be com.test.ObjectA$ObjectB
.public static class ObjectB...
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.