发表于: 2020-01-16 23:56:26

1 1151


今天完成的事情:


今天写表的1对多查询  在多的表力添加 1的主键id



<resultMap id="twoWorkMap" type="pojo.twowork" >
   <id property="twoId" column="two_id" jdbcType="BIGINT"/>
   <result property="twoworkName" column="twowork_name" jdbcType="VARCHAR" />
   <result property="state" column="state" jdbcType="TINYINT"/>
   <result property="createAt" column="create_at" jdbcType="BIGINT"/>
   <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
   <result property="updateAt" column="update_at" jdbcType="BIGINT"/>
   <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
   <result property="oneId" column="one_id" jdbcType="BIGINT"/>


尝试使用join语句

<!--    主页面 重置-->
   <select id="findAll" resultMap="twoWorkMap">
SELECT o.onework_name,
t.two_id,
t.twowork_Name,
t.state,
t.create_at,
t.create_by,
t.update_at,
t.update_by
FROM onework o INNER JOIN twowork t
ON o.one_id = t.one_id
</select>


虽然查询成功了 但还是没有我要查询的onework表  oneworkName的结果


增加了  association 

但查询结果还是一样

<resultMap id="twoWorkMap" type="pojo.twowork" >
   <id property="twoId" column="two_id" jdbcType="BIGINT"/>
   <result property="twoworkName" column="twowork_name" jdbcType="VARCHAR" />
   <result property="state" column="state" jdbcType="TINYINT"/>
   <result property="createAt" column="create_at" jdbcType="BIGINT"/>
   <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
   <result property="updateAt" column="update_at" jdbcType="BIGINT"/>
   <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
   <result property="oneId" column="one_id" jdbcType="BIGINT"/>
   <association property="onework" javaType="pojo.onework">
       <id property="oneId" column="one_id" javaType="BIGINT"/>
               <result property="oneworkName" column="onework_name" javaType="VARCHAR"/>
   </association>
</resultMap>




明天计划的事情:

推进任务



返回列表 返回列表
评论

    分享到