myibatis 嵌套查询

来源:互联网 发布:物流软件制作 编辑:程序博客网 时间:2024/05/22 12:22

http://www.mybatis.org/mybatis-3/zh/sqlmap-xml.html

实现复杂的嵌套有俩种方式

1:类似于这种:<collection property="posts"javaType="ArrayList"column="id"ofType="Post"select="selectPostsForBlog"/>

2:完全使用sql方式 <collection property="posts"ofType="Post"/>


俩点总结:

1:尽量使用第二种,查询一次数据库,第一种会出现1+N次扫描

2:第二种使用的时候,一定得带ID字段,(非常重要)







0 0
原创粉丝点击