http://www.mybatis.org/mybatis-3/zh/sqlmap-xml.html
映射器里面最主要的是配置了SQL 语句,也解决了我们的参数映射和结果集映射的问题。一共有8 个标签:
cache – 给定命名空间的缓存配置(是否开启二级缓存)。
cache-ref – 其他命名空间缓存配置的引用。这两个标签我们在讲解缓存的时候会详细讲到。
resultMap – 是最复杂也是最强大的元素,用来描述如何从数据库结果集中来加载对象。
<resultMap id="BaseResultMap" type="Employee">
<id column="emp_id" jdbcType="INTEGER" property="empId"/>
<result column="emp_name" jdbcType="VARCHAR" property="empName"/>
<result column="gender" jdbcType="CHAR" property="gender"/>
<result column="email" jdbcType="VARCHAR" property="email"/>
<result column="d_id" jdbcType="INTEGER" property="dId"/>
</resultMap>
sql – 可被其他语句引用的可重用语句块。
<sql id="Base_Column_List">
emp_id, emp_name, gender, email, d_id
</sql>
增删改查标签:
insert – 映射插入语句
update – 映射更新语句
delete – 映射删除语句
select – 映射查询语句