今天遇到一个特别奇怪的问题,最后发现是自己对mybatis的学习还有待提高
返回类型可以用resultType,也可以用resultMap
resultType是直接表示返回类型的,而resultMap则是对外部ResultMap的引用
举个例子:
resultMap:
<select id="findByContract" resultMap="BaseResultMap">
select
*
from
user
where
tel=#{tel}
</select>
resultType:
<select id="getCountGroupbyUserSex" resultType="com.iswust.controller.vo.stat.StatUserSexBean">
select sex as
type,count(*) as count from user group by sex;
</select>
<select id="findConnectByid" resultType="java.lang.String">
select
tel
from
user
id=#{user_id}
</select>
以后再也不要犯这么愚蠢的错误啦