<resultMap type="com.cloudsoaring.web.course.entity.PlanNodeEntity" id="selectPlanNodeMap"> <result property="id" column="ID"/> <result property="planId" column="PLAN_ID"/> <result property="parentId" column="PARENT_ID"/> <result property="level" column="LEVEL"/> <result property="nodeOrder" column="NODE_ORDER"/> <result property="content" column="CONTENT"/> <result property="createDate" column="CREATE_DATE"/> <result property="createUser" column="CREATE_USER"/> <result property="updateDate" column="UPDATE_DATE"/> <result property="updateUser" column="UPDATE_USER"/> <result property="nodeName" column="NODE_NAME"/> <collection property="childPlanNodes" column="{parentId=id}" select="selectChildPlanNode" /> </resultMap> <!-- 根据计划id检索父节点信息 --> <select id="selectPlanNodeList" resultMap="selectPlanNodeMap"> SELECT ID , PLAN_ID, PARENT_ID, LEVEL, NODE_ORDER, CONTENT, CREATE_DATE, CREATE_USER, UPDATE_DATE, UPDATE_USER, NODE_NAME FROM tb_plan_node where PLAN_ID=#{planId} and LEVEL=1 ORDER BY NODE_ORDER </select> <!-- 根据父节点id检索子节点信息 --> <resultMap type="com.cloudsoaring.web.course.entity.PlanNodeEntity" id="selectChildPlanNodeMap"> <result property="id" column="ID"/> <result property="planId" column="PLAN_ID"/> <result property="parentId" column="PARENT_ID"/> <result property="level" column="LEVEL"/> <result property="nodeOrder" column="NODE_ORDER"/> <result property="content" column="CONTENT"/> <result property="createDate" column="CREATE_DATE"/> <result property="createUser" column="CREATE_USER"/> <result property="updateDate" column="UPDATE_DATE"/> <result property="updateUser" column="UPDATE_USER"/> <result property="nodeName" column="NODE_NAME"/> <collection property="nodeCourses" column="{planNodeId=id}" select="searchPlanCourse" /> </resultMap> <select id="selectChildPlanNode" resultMap="selectChildPlanNodeMap"> SELECT ID , PLAN_ID, PARENT_ID, LEVEL, NODE_ORDER, CONTENT, CREATE_DATE, CREATE_USER, UPDATE_DATE, UPDATE_USER, NODE_NAME FROM tb_plan_node where PARENT_ID=#{parentId} and LEVEL=2 </select>
原文:http://www.cnblogs.com/Fang-Z/p/5242868.html