mybatis class contains class problem

<?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.digital.sfplan.mapper.SfPlanTaskMapper">
<select id="list" resultMap="idResult11">
select * from dep_sfplan_task
</select>

<resultMap type="com.digital.sfplan.model.SfPlanTaskDbModel" id="idResult11">
         <id property="taskId" column="taskId"/>
         <result property="periodId" column="periodId"/>
          <result property="taskType" column="taskType"/>
        <association property="sfPlanPeirodModel" javaType="com.digital.sfplan.model.SfPlanPeriodDbModel">
             <id property="periodId" column="periodId"/>
             <result property="planId" column="planId"/>
             <result property="periodType" column="periodType"/>
         </association>
     </resultMap>

</mapper>


Writing this directly will not automatically match it for you.




So in fact select and column are partners


Then I did a two-level nesting 


<?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.digital.sfplan.mapper.SfPlanTaskMapper">


<select id="list" resultMap="idResult11">
select * from dep_sfplan_task
</select>

<resultMap type="com.digital.sfplan.model.SfPlanTaskDbModel" id="idResult11">
         <id property="taskId" column="taskId"/>
         <result property="periodId" column="periodId"/>
         <result property="taskType" column="taskType"/>
         <result property="startAt" column="startAt"/>
         <result property="weekOfTaskStart" column="weekOfTaskStart"/>
         <result property="daysOfTaskStart" column="daysOfTaskStart"/>
         <result property="displayOfTaskStart" column="displayOfTaskStart"/>
         <result property="message" column="message"/>
         <result property="unsubscribe" column="unsubscribe"/>
         <result property="enabled" column="enabled"/>
         <result property="createTime" column="createTime"/>
         <result property="creatorId" column="creatorId"/>
         <result property="updateTime" column="updateTime"/>
         <result property="updatorId" column="updatorId"/>
         <result property="deleteFlag" column="deleteFlag"/>
         <association property="sfPlanPeirodModel" column="periodId" select="idGetPeriod">
             <id property="periodId" column="periodId"/>
              <result property="planId" column="planId"/>
             <result property="periodType" column="periodType"/> 
             
             <association property="sfPlanModel" column="planId" javaType="com.digital.sfplan.model.SfPlanDbModel" select="idGetPlan111">
            <id property="planId111" column="planId"/>
            <result property="title" column="title"/>
            <result property="departmentId" column="departmentId"/>
            <result property="doctorId" column="doctorId"/>
            <result property="comment" column="comment"/>
            <result property="enabled" column="enabled"/>
            <result property="createTime" column="createTime"/>
            <result property="creatorId" column="creatorId"/>
            <result property="updateTime" column="updateTime"/>
            <result property="updatorId" column="updatorId"/>
            <result property="deleteFlag" column="deleteFlag"/>
          </association> 
         </association> 
    </resultMap>
         
    <select id="idGetPeriod" parameterType="java.lang.String" resultType="com.digital.sfplan.model.SfPlanPeriodDbModel">
        SELECT periodId,planId,periodType FROM dep_sfplan_period  
    </select>
    
    <select id="idGetPlan111" parameterType="java.lang.String" resultType="com.digital.sfplan.model.SfPlanDbModel">
        SELECT planId as ,title,departmentId,doctorId,comment,enabled,createTime,creatorId,updateTime,updatorId,deleteFlag FROM dep_sfplan
    </select>


</mapper>


The second layer couldn't even match. Best to miss riding sister. In the end I didn't understand why.


In the end, only a big killer can be used, a sql statement.


<?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.digital.sfplan.mapper.SfPlanTaskMapper">


<select id="list" resultMap="idResult11">
select * from dep_sfplan_task a,dep_sfplan_period b,dep_sfplan c where a.periodId=b.periodId and c.planId=b.planId
</select>

<resultMap type="com.digital.sfplan.model.SfPlanTaskDbModel" id="idResult11">
         <id property="taskId" column="taskId"/>
         <result property="periodId" column="periodId"/>
         <result property="taskType" column="taskType"/>
         <result property="startAt" column="startAt"/>
         <result property="weekOfTaskStart" column="weekOfTaskStart"/>
         <result property="daysOfTaskStart" column="daysOfTaskStart"/>
         <result property="displayOfTaskStart" column="displayOfTaskStart"/>
         <result property="message" column="message"/>
         <result property="unsubscribe" column="unsubscribe"/>
         <result property="enabled" column="enabled"/>
         <result property="createTime" column="createTime"/>
         <result property="creatorId" column="creatorId"/>
         <result property="updateTime" column="updateTime"/>
         <result property="updatorId" column="updatorId"/>
         <result property="deleteFlag" column="deleteFlag"/>
         <association property="sfPlanPeirodModel" javaType="com.digital.sfplan.model.SfPlanPeriodDbModel">
             <id property="periodId" column="periodId"/>
              <result property="planId" column="planId"/>
             <result property="periodType" column="periodType"/> 
             
             <association property="sfPlanModel"  javaType="com.digital.sfplan.model.SfPlanDbModel" >
            <id property="planId" column="planId"/>
            <result property="title" column="title"/>
            <result property="departmentId" column="departmentId"/>
            <result property="doctorId" column="doctorId"/>
            <result property="comment" column="comment"/>
            <result property="enabled" column="enabled"/>
            <result property="createTime" column="createTime"/>
            <result property="creatorId" column="creatorId"/>
            <result property="updateTime" column="updateTime"/>
            <result property="updatorId" column="updatorId"/>
            <result property="deleteFlag" column="deleteFlag"/>
          </association> 
         </association> 
    </resultMap>
         
    <select id="idGetPeriod" parameterType="java.lang.String" resultType="com.digital.sfplan.model.SfPlanPeriodDbModel">
        SELECT periodId,planId,periodType FROM dep_sfplan_period  
    </select>
    
    <select id="idGetPlan111" parameterType="java.lang.String" resultType="com.digital.sfplan.model.SfPlanDbModel">
        SELECT planId ,title,departmentId,doctorId,comment,enabled,createTime,creatorId,updateTime,updatorId,deleteFlag FROM dep_sfplan
    </select>


</mapper>




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326092120&siteId=291194637