你的位置:首页 > 软件开发 > ASP.net > MyBatis的getMapper()接口、resultMap标签、Alias别名、 尽量提取sql列、动态操作

MyBatis的getMapper()接口、resultMap标签、Alias别名、 尽量提取sql列、动态操作

发布时间:2016-08-29 16:00:04
一、getMapper()接口  解析:getMapper()接口 IDept.class定义一个接口,     挂载一个没有实现的方法,特殊之处,借楼任何方法,必须和小配置中id属性是一致的     通过代理:生成接口的实现类名称,在MyBatis底层维护名称$$Dept_ab ...

一、getMapper()接口

  解析:getMapper()接口 IDept.class定义一个接口,

     挂载一个没有实现的方法,特殊之处,借楼任何方法,必须和小配置中id属性是一致的

     通过代理:生成接口的实现类名称,在MyBatis底层维护名称$$Dept_abc,selectDeptByNo()

     相当于是一个强类型

Eg

  第一步:在cn.happy.dao中定义一个接口   

package cn.happy.dao;import java.util.List;import cn.happy.entity.Dept;public interface IDeptDao {  //查看全部---------getAllDept要和小配置里面的id一样    public List<Dept> getAllDept();}
<resultMap type="cn.resultMap.enetity.Emp" id="empMap"> <id property="empId" column="EMPID"/> <result property="empName" column="EMPNAME"/> <result property="empCity" column="EMPCITY"/> <!-- 员工角度 多的一方,嵌入一的一方的各个属性请使用association --> <association property="dept" javaType="cn.resultMap.enetity.Dept"> <result property="deptName" column="DEPTNAME"/> <result property="deptNo" column="DEPTNO"/> </association> </resultMap> <select id="getAllEmps" resultMap="empMap"> select e.*,d.* from Emp e,Dept d where e.deptNo=d.deptNo </select> </mapper>

原标题:MyBatis的getMapper()接口、resultMap标签、Alias别名、 尽量提取sql列、动态操作

关键词:sql

sql
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。