码迷,mamicode.com
首页 > 其他好文 > 详细

<association>关联的结果查询

时间:2018-05-26 20:21:13      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:cart   span   etc   style   bat   soc   pre   HERE   map   

association:用于对象间包含关系映射

<mapper namespace="org.apache.ibatis.submitted.associationtest.Mapper">  
    <resultMap type="org.apache.ibatis.submitted.associationtest.Car" id="carResult">  
        <id column="carid" property="id"/>  
        <result column="cartype" property="type"/>  
        <association property="engine" resultMap="engineResult"/>  
        <association property="brakes" resultMap="brakesResult"/>  
    </resultMap>  
    <resultMap type="org.apache.ibatis.submitted.associationtest.Engine" id="engineResult">  
        <result column="enginetype" property="type"/>  
        <result column="enginecylinders" property="cylinders"/>  
    </resultMap>  
    <resultMap type="org.apache.ibatis.submitted.associationtest.Brakes" id="brakesResult">  
        <result column="brakesType" property="type"/>  
    </resultMap>  
    <select id="getCars" resultMap="carResult">  
        select * from cars  
    </select>  
    <select id="getCarsNonUnique" resultMap="carResult">  
        select 1 as carid, cartype, enginetype, enginecylinders, brakestype from cars  
    </select>  
    <select id="getCars2" resultMap="carResult">  
        select 1 as carid, cartype, enginetype, enginecylinders, brakestype from cars where carid in (1,2)  
    </select>  
</mapper>  

 

<association>关联的结果查询

标签:cart   span   etc   style   bat   soc   pre   HERE   map   

原文地址:https://www.cnblogs.com/yifanSJ/p/9094025.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!