mybatis中resultType可选类型:
1,java的基础类型及其包装类int,double和java.lang.Integer,java.lang.Double等
2,实体类,自己定义的实体类
3,map类型,如果使用resultMap可以使用自定义map;
4,集合,即返回的是一个List集合,其中该集合的类型可以为1,2,3中提到的类型
Map的demo:Dao层的返回类型为Map<String, Object>key是对应的column值,value是数据中的数据
<mapper namespace="com.xx.xx.dao.PersonMapper">
<!-- 返回值为Map<String,Object>,resultType为map-->
<select id="getPerson" resultType="map">
select name,age,sex from Person where id=#{id}
</select>
</mapper>
Map的demo2:Dao层的返回类型为personInfoMap里的数据(适合于返回自定义所需数据)
<select id="findByIdCard" resultMap="personInfo">
<mapper namespace="com.xx.xx.dao.PersonMapper">
<select id="getPersonInfo" resultType="personInfoMap">
select name,age,sex fr