[英]Ibatis filling up Nested object in Java
I have one java class which resembles to我有一个 java class 类似于
class A{
String a;
B bclass;
}
class B{
String b;
String c;
}
my ibatis query is: Select a,b,c from A_TABLE
and resultmap I want is something like this where I can fill properties of class B (Bb,Bc) as well.我的 ibatis 查询是:
Select a,b,c from A_TABLE
和我想要的结果图是这样的,我可以在其中填充 class 的属性(以及 Bc)
<resultMap class="A" id="resmap">
<result property="a" column="A" jdbcType="VARCHAR"/>
<result property="bclass.b" column="B" jdbcType="VARCHAR"/>
<result property="bclass.c" column="C" jdbcType="VARCHAR"/>
</resultmap>
any idea how I can fill this object A from ibatis query so I have all 3 a,b,c properties filled?知道如何从 ibatis 查询中填充这个 object A,所以我已经填充了所有 3 个 a、b、c 属性?
The mapping of inner objects is made with association
tag.内部对象的映射是使用
association
标签进行的。 You need something like this:你需要这样的东西:
<resultMap id="resmap" type="A">
<result property="a" column="a"/>
<association property="b" javaType="B">
<result property="b" column="b_b"/>
<result property="c" column="b_c"/>
</association>
</resultMap>
Check documentation as well, it's explained in details.检查文档以及详细说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.