苦逼码农的博客

你是风儿我是沙

mybatis result 多表关联查询
<sql id="pZoneCoordinateAllField">coordinateAreaId,coordinateNumber,coordinateId,zoneId,coordinateAreaName,coordinateLongitude,coordinateAltitude,longitudeDegree,longitudeMinute,longitudeSecond,altitudeDegree,altitudeMinute,altitudeSecond</sql>  
	<resultMap type="ProtectionZone" id="pzMap">  
    <!-- 传递两个字段 -->  
    <collection property="coordinates" javaType="ArrayList"   
     column="{zoneId = zoneId}" ofType="ProtectionZoneCoordinate" select="findProtectionZoneCoordinate"/>  
    </resultMap>  
	<select id="findProtectionZoneCoordinate" resultType="ProtectionZoneCoordinate">  
    select <include refid="pZoneCoordinateAllField" /> from protectionZoneCoordinate  
     where zoneId=#{zoneId} ;   
    </select>
	
    <select id="selectId" resultMap="pzMap">
		select * from (
		select a.zonePeriodStartMonth,
		a.zonePeriodEndMonth,
		a.zoneStatus,
		a.zoneOrgStaffCount,
		a.zoneOrgTechStaffCount,
		(select fullName from sys_user where userId=a.zoneCreator) as createName,
		a.zoneOrgLawEnforcerCount,
		a.zoneArea,
		a.zoneOrgContactEmail,
		a.zoneOrgFundOrgin,
		a.zoneOrgWorkerCount,
		a.zoneCoreArea,
		a.zoneExperimentalArea,
		a.zoneOrgFixedAnnualFund,
		a.zoneOrgTotalAsset,
		a.zoneId,
		a.zoneSeries,
		a.zoneLevel,
		a.zoneCreator,
		a.zoneCreateTime,
		a.zoneEditTime,
		a.zoneOrgLevel,
		a.zoneOrgType,
		a.zoneNumber,
		a.zoneName,
		a.zoneAreaCode,
		a.zoneAdditionalSpecies,
		a.zoneSurveillanceId,
		a.zoneOrgName,
		a.zoneOrgContactMobile,
		a.zoneOrgLegalPerson,
		a.zoneOrgContactName,
		a.zoneOrgRelation,
		a.zoneOrgNameLevel,
		a.zoneOrgAreaOwnership,
		a.zoneOrgContactAddress,
		a.zoneOrgContactZip,
		a.zoneOrgContactPhone,
		a.isEnable
		from protectionZone a
		) as j
		where zoneId=#{zoneId}
	</select>


阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

mybatis result 多表关联查询

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭