zoukankan      html  css  js  c++  java
  • 08-one2many

        <!-- 多表连接查询 -->

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.abc.dao.ICountryDao"> <!-- 多表连接查询 --> <!-- 定义结果映射关系 --> <resultMap type="Country" id="countryMap"> <id column="cid" property="cid"/> <result column="cname" property="cname"/> <!-- ofType解释为element of type ,元素类型 --> <collection property="ministers" ofType="Minister"> <id column="mid" property="mid"/> <result column="mname" property="mname"/> </collection> </resultMap> <select id="selectCountryById" resultMap="countryMap"> select cid,cname,mid,mname from country,minister where cid=countryId and cid=#{xxx} </select> </mapper>

     多表单独查询、

    <mapper namespace="com.abc.dao.ICountryDao">
    
        <!-- 多表单独查询 -->
        
        <select id="selectMinisterByCountry" resultType="Minister">
            select mid,mname from minister where countryId=#{ooo}
        </select>
    
        <!-- 定义结果映射关系 -->
        <resultMap type="Country" id="countryMap">
            <id column="cid" property="cid"/>
            <result column="cname" property="cname"/>
            <!-- ofType解释为element of type ,元素类型 -->
            <collection property="ministers" 
                        ofType="Minister"
                        select="selectMinisterByCountry"
                        column="cid"/>
        </resultMap>
    
        <select id="selectCountryById" resultMap="countryMap">
            select cid,cname from country where cid=#{xxx}
        </select>
    
    </mapper>
  • 相关阅读:
    CentOS 7 网卡命名修改为eth0格式
    Sublime Text3下的markdown插件的安装及配置
    json-lib 之jsonConfig详细使用(转载写的不错)
    IDEA快捷键【收藏】
    阿里云安装nginx 和 php-fpm
    sed 神器
    非root模式下安装mysql php小记
    一个不错的vim配置
    sublime安装sftp和ctags插件
    取得某个数组前key大 PHP实现
  • 原文地址:https://www.cnblogs.com/csslcww/p/9912298.html
Copyright © 2011-2022 走看看