多表嵌套查询:
<mapper namespace="com.sica.mapper.UserMapper">
<resultMap id="BaseResultMap" type="com.sica.domain.User">
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="queryForListMap" type="com.sica.domain.User">
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<collection property="roles" javaType="java.util.List" ofType="com.sica.domain.Role">
<id column="r_id" property="id" jdbcType="VARCHAR" />
<result column="r_name" property="name" jdbcType="VARCHAR" />
<result column="r_jsms" property="jsms" jdbcType="VARCHAR" />
<result column="r_bz" property="bz" jdbcType="VARCHAR" />
<result column="r_jlzt" property="jlzt" jdbcType="INTEGER" />
<result column="r_glbm" property="glbm" jdbcType="VARCHAR" />
</collection>
</resultMap>
<select id="queryForList" resultMap="queryForListMap">
SELECT
u.id,
u.username,
u.password,
r.id r_id,
r.name r_name,
r.jsms r_jsms,
r.bz r_bz,
r.jlzt r_jlzt,
r.glbm r_glbm
FROM
user u
LEFT JOIN
role r
ON
u.id = r.userid
</select>