首页 > 其他 > 详细

<association>关联的结果查询

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

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>关联的结果查询

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!