include refid="**"标签在mybatis中经常出现。
其实他的作用就相当于平时查询中的“*”。
在经常对某些字段进行操作的时候,可以将所有需要的字段包装到refid中。

</select>
    <select id="selectOne" resultMap="BaseResultMap">
        select
        <include refid="base_col_list"/>
        from entity_meta
        where id = #{entityId}
    </select>
   
      <sql id="base_col_list">
        id,
        zh_name,
        en_name,
        color,
        parent_entity_id,
        is_sys_source,
        recent_backup_time,
        is_backup
    </sql>
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐