zoukankan      html  css  js  c++  java
  • Mybatis一对多的写法

    实体类

    
    public class AntennaSystem implements Serializable {
    	private static final long serialVersionUID = 1L;
    	
    	/**
    	* 系统id
    	*/
        private String systemId;
    	
    	/**
    	* 系统名称
    	*/
        private String systemName;
    	
    	/**
    	* 部门id
    	*/
    	private String departId;
    
    	/**
    	 * 部门
    	 */
        private Department department;
    	
    	/**
    	* 站主键id
    	*/
    	private String stationId;
    
    	/**
    	 * 站
    	 */
        private Station station;
    	/**
    	 * 扩展属性
    	 */
    	private List<ExtendedAttr> extendedAttrs;
    
    	/**
    	 * 分系统
    	 */
    	private List<Subsystem> subsystems;
    }
    

    Mapper.xml

    
        <!-- 可根据自己的需求,是否要使用 -->
        <resultMap type="com.industry.txsp.entity.AntennaSystem" id="baseAntennaSystemMap">
            <result property="systemId" column="system_id"/>
            <result property="systemName" column="system_name"/>
            <result property="departId" column="depart_id"/>
            <result property="stationId" column="station_id"/>
            <result property="completeDate" column="complete_date"/>
            <result property="deliveryDate" column="delivery_date"/>
            <result property="qaDeadline" column="qa_deadline"/>
            <result property="systemNumber" column="system_number"/>
            <result property="remark" column="remark"/>
            <result property="createId" column="create_id"/>
            <result property="creator" column="creator"/>
            <result property="createTime" column="create_time"/>
            <result property="updateTime" column="update_time"/>
            <result property="isDeleted" column="is_deleted"/>
        </resultMap>
        
        <!--分开来写有利于解耦,更灵活-->
        <!--extends:可以继承一个已有的resultMap,指定resultMap的唯一标识(id)即可,但是在继承时,只能继承type类型一样的resultMap-->
        <resultMap extends="baseAntennaSystemMap" type="com.industry.txsp.entity.AntennaSystem" id="antennaSystemMap">
            <association property="department" resultMap="com.industry.txsp.mapper.DepartmentMapper.departmentMap"/>
            <association property="station" resultMap="com.industry.txsp.mapper.StationMapper.stationMap"/>
        </resultMap>
    
         
        <resultMap extends="antennaSystemMap" type="com.industry.txsp.entity.AntennaSystem" id="allAntennaSystemMap">
            <collection property="subsystems" resultMap="com.industry.txsp.mapper.SubsystemMapper.subsystemMap"/>
            <collection property="extendedAttrs" resultMap="com.industry.txsp.mapper.ExtendedAttrMapper.extendedAttrMap"/>
        </resultMap>
    
  • 相关阅读:
    1571:【例 3】凸多边形的划分
    1570:【例 2】能量项链
    2.25
    2.24 T2 牧场 by greens 1s 128M (pasture.cpp)
    2.24 T1 P3515 [POI2011]Lightning Conductor
    白嫖视频的方法
    2.24 T3 P1912 [NOI2009] 诗人小G
    2.24
    斜率优化
    windy数的补充——数位dp中如何求[a,b]区间内的方案数
  • 原文地址:https://www.cnblogs.com/junzifeng/p/12736313.html
Copyright © 2011-2022 走看看