MyBatis中,两表查询,使用
<resultMap id="ResultMap3" type="java.util.Map"> 查询的表的字段映射,例: <id column="id" property="id" jdbcType="VARCHAR"/> <result column="path" property="path" jdbcType="VARCHAR"/> <result column="file_size" property="fileSize" jdbcType="INTEGER"/> </resultMap>
范文:
<?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.njzykj.ms.dao.companyInfo.ZykjUnitInformationDao">
<resultMap id="BaseResultMap" type="com.njzykj.ms.entity.companyInfo.ZykjUnitInformation">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed May 30 16:42:45 CST 2018.
-->
<id column="ID" property="id" jdbcType="INTEGER"/>
<result column="company_id" property="companyId" jdbcType="INTEGER"/>
<result column="information_name" property="informationName" jdbcType="VARCHAR"/>
<result column="information_content" property="informationContent" jdbcType="VARCHAR"/>
<result column="company_floor" property="companyFloor" jdbcType="INTEGER"/>
<result column="classfiy" property="classfiy" jdbcType="CHAR"/>
<result column="parent_id" property="parentId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="left_lng_lat" property="leftLngLat" jdbcType="VARCHAR"/>
<result column="right_lng_lat" property="rightLngLat" jdbcType="VARCHAR"/>
<result column="information_message" property="informationMessage" jdbcType="VARCHAR"/>
<result column="effect_status" property="effectStatus" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="ResultMap3" type="java.util.Map">
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="path" property="path" jdbcType="VARCHAR"/>
<result column="file_size" property="fileSize" jdbcType="INTEGER"/>
<result column="file_desc" property="fileDesc" jdbcType="VARCHAR"/>
<result column="parent_id" property="parentId" jdbcType="VARCHAR"/>
<result column="create_at" property="createAt" jdbcType="TIMESTAMP"/>
<result column="file_name" property="fileName" jdbcType="VARCHAR"/>
</resultMap>
<select id="selectByCompanyId" resultMap="ResultMap3">
select * from zykj_unit_information as a , file_store as b
where a.company_id = #{companyId}
AND a.parent_id = b.parent_id
AND b.file_desc !=2
</select>
</mapper>