標籤:highlight 屬性 http 引用 select from mes coding resultmap
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><!--namespace:名稱空間 --><mapper namespace="cn.bdqn.mybatis.dao.EmpMapperPlus"><!--自訂某個javaBean的封裝規則 type:要自訂規則的javaBean類型 id:唯一標識,方便引用 --><resultMap type="cn.bdqn.mybatis.been.Emp" id="myEmp"><!--id定義主鍵會有底層最佳化指定主鍵列的封裝規則 column:指定哪一列property:指定對應的javaBean屬性 --><idcolumn="id" property="id"/><!--定義普通列封裝規則 --><resultcolumn="last_name"property="lastName"/><!-- 其他不指定的列會自動封裝,但是建議,如果我們寫了resultMap,我們就把所有列的映射都寫上 --><result column="email"property="email"/><result column="gender" property="gender"/></resultMap><!-- public Emp getEmpById(Integer id); --><!-- resultMap自訂結果集 resultType和resultMap只能二選一 --><select id="getEmpById" resultMap="myEmp">select * from emp where id=#{id}</select></mapper>
resultMap自訂某個javaBean的封裝規則源碼