mybatis 相关

1.xml 转义   

<![CDATA[ when min(starttime)<='12:00' and max(endtime)<='12:00' ]]> 

2.递归

  <resultMap id="BaseResultMap" type="org.sang.bean.Department">

    <id property="id" column="id"/>

    <result column="name" property="name"/>

    <result column="parentId" property="parentId"/>

    <result column="isParent" property="isParent"/>

     <collection property="children" ofType="org.sang.bean.Department" select="getDepByPid" column="id">

     </collection>

    </resultMap>

  <select id="getDepByPid" resultMap="BaseResultMap"> select d1.*from department d1 where d1.`parentId`=#{pid} AND d1.enabled=true; </select>

  <resultMap id="resAll" extends="BaseResultMap" type="EntityBaseResource">
        <collection property="children" ofType="resAll"
            column="{resID=res_id,belongTo=belong_to}" select="selectRecursionRes" />
    </resultMap>
3.实体关联
<association property="manager" column="manager_id" javaType="com.ytl.entity.ManagerUser" select="com.ytl.dao.ManagerUserDao.selectByPrimaryKey" fetchType="lazy">
</association>


posted @ 2021-08-24 17:43  笑对蓝天  阅读(17)  评论(0编辑  收藏  举报