在数据库中 主表 一对多 字表, 使用left join 查询?主表必然会出现 N+1的重复数据,
但是使用 collection
<collection property="privileges" ofType="Privilege">
<result property="id" column="priv_id"/>
<result property="name" column="priv_name"/>
<result property="url" column="priv_url"/>
</collection>
sql:
并在主表实体中添加List<Privilege> mybatis就可以自动把子表数据映射到主表,
我实在不理解 mybatis 是如何做的,
他是怎么知道那条数据是子表的数据,而且知道这条子表数据是对应的是哪条主表数据,
就好像sql 加上了group by
但我又觉得 mybatis应该不会干涉 sql
有没有懂点的大佬解决下????
慕勒9441395
奔奔波儿灞