SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE_BY_ID; if (tableInfo.isWithLogicDelete()) { sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo), tableInfo.getKeyColumn(), tableInfo.getKeyProperty(), tableInfo.getLogicDeleteSql(true, true)); SqlSource ...
我们以 student_score 表为例来说明: if+where 标签 SQL语句中 < if > 标签和代码中的 if 语句作用是一样的,都是条件判断。加上 if 标签的SQL语句会自动的去判断传入的条件是否为空。 1、< if >标签的使用 //会自动去判断传入的 name 和 math 是否为空, //如果name为空则SQL语句中不会拼接 name=?
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException { if (InterceptorIgnoreHelper.willIgnoreDataPermission(ms.getId())) { return; } PluginUtils.MPBoundSql mpBs = PluginUtils.mpBoundSql(...
fieldName = tableFieldAnnotation.value(); }else{ fieldName = convertToSnakeCase(field.getName()); }//根据字段的类型来选择不同的查询方式if(type == String.class) { wrapper.like(fieldName, value); }elseif(type == Long.class){ wrapper.eq(fieldName, value); }elseif(type == List.class...
1.if-where 因为采用了Mapper代理开发,我们可以通过写xml的形式来编写我们的SQL,动态SQL的特性也就在这一举动中所蕴育,在原有的Mapper文件里我们进行如下改造,让平平无奇的SQL焕然一新: select * from mybatis <where> <if test="status !=null"> and STATUS...
<iftest="cus.tenantCode != null and cus.tenantCode != '' ">when id=#{cus.id} then #{cus.tenantCode}</if> </foreach> </trim> <trim prefix="salary_common_type_id=case" suffix="end,"> <foreach collection="list" item="cus"> ...
<if></if>:类似于java中的条件判断if,没有<else>标签 <choose>标签 <choose> <when></when> <otherwise></otherwise> </choose> <foreach></forwach>:可以对数组、Map或实现了Iterable接口(如List、Set)的对象遍历。可实现in、批量更新、批量插入等。
1、使用<if></if>标签,实现关键词模糊查找 @Mapperpublic interfaceCompanyMapperextendsBaseMapper<CompanyEntity>{// 分页查询@Select(""+" select t.*,a.name_cn as company_name"+" from t_company t "+" join t_customer_company a on t.company_id=a.id"+" where <![CDATA[t.status <> 2]]>...
</if> <if test="condition.status != null and condition.status != ''"> and a.status = #{condition.status, jdbcType=VARCHAR} </if> <if test="condition.pairingStatus != null and condition.pairingStatus != ''"> and a.pairing_status = #{condition.pairingStatus, jdbcType=VARCHAR} ...
{this.key = key;this.desc = desc;}public static FieldFill getIgnore(int key) {FieldFill[] fis = FieldFill.values();for (FieldFill fi : fis) {if (fi.getKey() == key) {return fi;}}return FieldFill.DEFAULT;}public int getKey() {return this.key;}public String getDesc() {...