<sql id="roleCols">
id,role_name,note
</sql>
<select id="getRoleUserResultMap" parameterType="long" resultMap="roleMap">
select <include refid='roleCols' /> from t_role where id=#{id}
</select>
<insert id="" parameterType="" useGenerateKeys="true" keyProperty="id">
insert into t_role(<include refid='roleCols' />) values(#{roleName},#{note});
</insert>
另一种用法
<sql id="roleCols">
${alias}.id,${alias}.role_name,${alias}.note
</sql>
<select id="getRoleUserResultMap" parameterType="long" resultMap="roleMap">
select <include refid='roleCols'><property name="alias" value="r"></property></include> from t_role r where id=#{id}
</select>