传统返回类型设计
<mapper namespace="com.liubo.mapper.UserMapper">
<select id="selAllUser" resultType="com.liubo.domain.User">
select * from test_user
</select>
<select id="selUser" resultType="com.liubo.domain.User">
select * from test_user where id = #{0}
</select>
</mapper>
resultType:返回值类型设置的实在是太麻烦了
mybatis.xml:
<typeAliases>
<typeAlias type="com.liubo.domain.User"/>
</typeAliases>
UserMapper.xml:
当设置了<typeAlias>之后,返回值类型不区分大小写,USER User user都是可以的
<mapper namespace="com.liubo.mapper.UserMapper">
<select id="selAllUser" resultType="user">
select * from test_user
</select>
<select id="selUser" resultType="user">
select * from test_user where id = #{0}
</select>
</mapper>