[英]Dozer Mapping between primitive datatype and Custom object?
I have the following scenario : 我有以下场景:
Class A{
private List<Long> longList;
//getter and setter
}
Class B{
private List<C> listC;
//getter and setter
}
Class C{
private Long id;
//getter and setter
}
Now, I want to convert between longList
and C
. 现在,我想在longList
和C
之间进行转换。 I found the following mapping : 我找到了以下映射:
<mapping>
<class-a>A</class-a>
<class-b>B</class-b>
<field>
<a>longList</a>
<b>listC</b>
<a-hint>java.lang.Long</a-hint>
<b-hint>C</b-hint>
</field>
</mapping>
I am not sure whether the above mapping is the proper solution or not. 我不确定上面的映射是否是正确的解决方案。 Can I set up a mapping between long
and C
, such that long gets mapped to C.id
? 我可以在long
和C
之间设置映射,以便long被映射到C.id
吗?
You could try mapping Long to C like so: 您可以尝试将Long映射到C,如下所示:
<mapping>
<class-a>A</class-a>
<class-b>B</class-b>
<field>
<a>longList</a>
<b>listC</b>
<field>
</mapping>
<mapping>
<class-a>java.lang.Long</class-a>
<class-b>C</class-b>
<field>
<a>this</a>
<b>id</b>
<field>
</mapping>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.