resultMap自訂某個javaBean的封裝規則源碼

來源:互聯網
上載者:User

標籤: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的封裝規則源碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.