一。实体属性名与表字段名不匹配问题
http://blog.csdn.net/u010837612/article/details/45670801,从中也可以知道mybatis的属性映射xml文件里resultMap 元素的作用,它是 MyBatis 中最重要最强大的元素。
ps:现版本的mybatis变的更便利了许多,例如:
1.使用注解:
@Select("select * from user")
public List<User> getUserList();
或xml配置:
<mapper namespace="com.spring.Dao.api.IUserDoa">
<select id="getUsers" resultType="User">
select * from user
</select>
</mapper>
可直接返回一个List,无需其他配置
2. 数据库字段名(例如 user_id) 和java字段名 (例如 userId)能自动映射上,无需在xml中写resultMap建立对应关系。
三。
在dao包下创建一个UserMapper.xml文件作为上一步创建的DAO接口的实现。