mapper中 <include refid="XXX"></include>标签 <sql id="XXX">标签

引言

include标签用法是引用sql片段
sql标签 是书写sql片段 被include 引用的

直接上代码:

<sql id="query_where">
        <where>
            excel_file_id = #{excelFileId}
            <if test="field1 != null">
                AND field1 = #{field1}
            </if>

            <if test="field2 != null">
                AND field2 = #{field2}
            </if>

            <if test="field3 != null">
                AND field3 = #{field3}
            </if>
        </where>
    </sql>

引用:

SELECT * FROM t_excel_file_detail
        <include refid="query_where"></include>
public List<ModelMajorListVo> modelMajorList() { //目前确定顶级类型为机型 查出他下级字典 List<ModelMajorListVo> modelMajorListVos = dictionaryMapper.noteTree(); return modelMajorListVos; } @EqualsAndHashCode(callSuper = true) @ApiModel("机型专业联动查询vo") @Data @Accessors(chain = true) public class ModelMajorListVo extends AbstractObject implements Serializable { @ApiModelProperty("主键id") private Long id; @ApiModelProperty("字典类型中文名称") private String typeName; @ApiModelProperty("字典类型") private String dictionaryType; @ApiModelProperty("展示值枚举") private String keyWord; @ApiModelProperty("展示值") private String showText; @JsonInclude(JsonInclude.Include.NON_EMPTY) @ApiModelProperty("子集列表") private List<ModelMajorListVo> children; } <resultMap id="BaseResultMap" type="com.iflytek.ebg.gz.tms.pc.standard.courseManagement.doamin.vo.ModelMajorListVo"> <id column="id" property="id"/> <result column="type_name" property="typeName"/> <result column="dictionary_type" property="dictionaryType"/> </resultMap> <resultMap id="NodeTreeResult" type="com.iflytek.ebg.gz.tms.pc.standard.courseManagement.doamin.vo.ModelMajorListVo" extends="BaseResultMap"> <!-- ofType:返回类型--> <collection property="children" column="id" ofType="com.iflytek.ebg.gz.tms.pc.standard.courseManagement.doamin.vo.ModelMajorListVo" javaType="java.util.ArrayList" select="nextNoteTree"> </collection> </resultMap> <sql id="Base_Column_List"> id, type_name, dictionary_type, key_word, show_text </sql> <!-- nextNoteTree:循环获取子节点数据,知道叶子节点结束;--> <select id="nextNoteTree" resultMap="NodeTreeResult"> select <include refid="Base_Column_List"/> from t_dictionary b where b.parent_id = #{id} and b.dictionary_type = 'major' and b.is_deleted = 'N' </select> <!-- noteTree :获取所有父级节点数据--> <select id="noteTree" resultMap="NodeTreeResult"> select <include refid="Base_Column_List"/> from t_dictionary a where a.dictionary_type = 'model' and a.is_deleted = 'N' </select> 报错 “nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘id’ in ‘class com.kingbase8.util.KBobject’”, 避免使用嵌套 select 查询 适配金仓数据库 全量返回
最新发布
12-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值