关于上一节的快速入门,还需要补充的MyBatis映射文件的知识如下,首先我把UserMapper.xml映射文件里面的代码放到下面,然后再详细概述
xxxxxxxxxx
<mapper namespace="zidingyi_userMapper">
<select id="findAll" resultType="com.huanf.domain.User">
<!--查询结果会放到上面那行的resultType路径下-->
select * from user
</select>
</mapper>
1、映射文件DTD约束头
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2、根标签
<mapper>
3、命名空间,与下面语句的id一起组成查询的标识
namespace="zidingyi_userMapper"
4、查询操作,可选的还有insert、update、delete
xxxxxxxxxx
<select>
5、查询结果对应的实体类型
xxxxxxxxxx
resultType="com.huanf.domain.User
6、语句的id标识,与上面的命名空间一起组成查询的标识
xxxxxxxxxx
id="findAll"
7、要执行的sql语句
xxxxxxxxxx
select * from user
MyBatis快如入门总结: 操作实体,从而间接操作表 ; 查询表,从而间接封装实体