栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Mybatis insert 时SQL报错 check for the right syntax to use near ‘‘ at line 1

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Mybatis insert 时SQL报错 check for the right syntax to use near ‘‘ at line 1

在写Mybatis+springboot项目时,调用某mapper接口发生报错

### The error occurred while setting parameters
### SQL: insert into imooc_mall_cart
Caused by: 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 '' at line 1

SQL后半句也没显示出来,而且near也没有定位到,搜索了很多帖子之后,找到一篇13年的帖子有类似情况,楼主说自己传了空的循环体进去导致insert 空,所以报了这个error,我觉得有道理,找到调用mapper的接口发现传参疏忽,把一个空值传进去了

validProduct(productId,count);
Cart cart = cartMapper.selectCartByUserIDAndProductID(userId, productId);
if (cart==null) {
    //该商品之前不在购物车
    Cart newCart = new Cart();
    newCart.setUserId(userId);
    newCart.setProductId(productId);
    newCart.setQuantity(count);
    newCart.setSelected(Constant.Cart.SELECTED);
    cartMapper.insertSelective(newCart);//这里应该传newCart,结果我把cart传进去了
}

找到问题所在,现已解决。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/736211.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号