传入参数类型parameterType
不需要写,有自动的类型转换处理器
返回参数类型resultType,resultMap
resultType值为返回类型的全限定名或者别名
resultMap显示自定义结果映射
//设置resultMap。指定唯一的id结果集,能让速度更快
<resultMap id="userResultMap" type="User">
<id property="id" column="user_id" />
<result property="username" column="user_name"/>
<result property="password" column="hashed_password"/>
</resultMap>
//使用resultMap
<select id="selectUsers" resultMap="userResultMap">
select user_id, user_name, hashed_password
from some_table
where id = #{id}
</select>
resultMap隐式结果映射:在sql中设置结果映射
<select id="selectUsers" resultType="User">
select
user_id as "id",
user_name as "userName",
hashed_password as "hashedPassword"
from some_table
where id = #{id}
</select>
类型别名
<!-- mybatis-config.xml 中 -->
<typeAlias type="com.someapp.model.User" alias="User"/>
自动结果映射
mapUnderscoreToCamelCase=true
下划线命名自动转驼峰命名