Springboot项目 MybatisPlus 使用 @tablelogic 影响updateById的SQL语句

在项目过程中,我使用@TableLogic规定逻辑删除后,在使用updateById时 被标记@TableLogic的字段总是出现在SQL语句的WHERE条件后面,并且始终是一个常量(这里是1),如下是源码和测试的log输出,目前还不明白到底怎么回事~ 已经排错一天了。。。

// Entity层
 */
	@TableLogic
	private Integer isShow;
	/**
	 * 检索首字母
	 */
	private String firstLetter;
	/**
	 * 排序
	 */
	private Integer sort;
// Controller层
	/**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("commodity:brand:update")
    public R update(@RequestBody BrandEntity brand){
		brandService.updateById(brand);
        return R.ok();
    }
// application.yml
mybatis-plus:
  mapper-locations: classpath:/mapper/**/*.xml
#  主键自增
  global-config:
    db-config:
      id-type: auto
#      逻辑删除
      logic-delete-value: 0  #已删除
      logic-not-delete-value: 1  #未删除
// pom.xml
<dependency>
      <groupId>com.baomidou</groupId>
      <artifactId>mybatis-plus-boot-starter</artifactId>
      <version>3.2.0</version>
</dependency>
// 启动类
@SpringBootApplication
public class HsplivingCommodityApplication {

	public static void main(String[] args) {
		ConfigurableApplicationContext ioc = SpringApplication.run(HsplivingCommodityApplication.class, args);
		System.out.println(ioc);
	}
}
// 测试log输出
### Error updating database.  Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id=1   AND is_show=1' at line 1
### The error may exist in com/leon/commodity/dao/BrandDao.java (best guess)
### The error may involve com.leon.commodity.dao.BrandDao.updateById-Inline
### The error occurred while setting parameters
### SQL: UPDATE commodity_brand    WHERE id=?   AND is_show=1
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; 

在这里插入图片描述

// 数据库
CREATE TABLE `commodity_brand` (
id BIGINT NOT NULL AUTO_INCREMENT COMMENT 'id', `name` CHAR(50) COMMENT '品牌名',
logo VARCHAR(1200) COMMENT 'logo',
description LONGTEXT COMMENT '说明',
is_show TINYINT COMMENT '显示',
first_letter CHAR(1) COMMENT '检索首字母',
sort INT COMMENT '排序',
PRIMARY KEY (id)
)CHARSET=utf8mb4 COMMENT='家居品牌';

跪求基友们指点~~

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值