mybatis中关于组合的查询
在配置resultMap标签的时候,我们可以在里面配置一个association标签
<association property="user" javaType="user">
<id property="id" column="id"></id>
<result column="user_name" property="userName"></result>
<result column="address" property="address"></result>
<result column="sex" property="sex"></result>
<result column="birthday" property="birthday"></result>
</association>
以上方法就可以解决一个类中包含另外一个类的问题。
但是,如果一个类中包含另外一个类的list集合呢?
这时候就需要用到collection标签了
<collection property="accounts" ofType="account">
<!--account表示封装的类型-->
<id column="aid" property="id"></id>
<result column="uid" property="uid"></result>
<result column="money" property="money"></result>
</collection>
本文介绍了在Mybatis中如何配置resultMap,特别是当类中包含另一个类的list集合时,使用association和collection标签的解决方案。

3132

被折叠的 条评论
为什么被折叠?



