1、resultType的使用
<select id="findUserById" parameterType="int" resultType="com.bbz.pojo.UserInfo">
select * from userInfo where id = #{id}
</select>
2、resultMap的使用
<resultMap id="userResultMap" type="User">
<id property="id" column="id" />
<result property="username" column="username"/>
<result property="password" column="password"/>
</resultMap>
<select id="findUserById" parameterType="int" resultMap="userResultMap">
select * from userInfo where id = #{id}
</select>
3、总结
相同点:
(1)resultType和resultMap都是标识sql语句的返回值类型
不同点:
(1)resultMap需要自己先定义,使用resultType的时候,要保证结果集的列名与java对象的属性相同,而resultMap则不用