QHYxx 2022-04-09 19:37 采纳率: 66.7%
浏览 491

Mybatis updateById 修改数据出错 解决不了了困扰我一下午了

Serviceimpl 这样写的

    // 修改用户信息
    public int updateByid(User user){
        int i = userMapper.updateById(user);
        return i;
    }

controller里面这样写的


// 修改用户信息
    @PostMapping("update")
    public int update (@RequestBody User user){
        System.out.println("修改操作开始==============================================");
        int update = userService.updateByid(user);
        System.out.println(update+"update应该返回的值");
        System.out.println("修改操作完成==============================================");
        return update;
    }

报错了

JDBC Connection [HikariProxyConnection@1765617826 wrapping com.mysql.cj.jdbc.ConnectionImpl@39f50341] will not be managed by Spring
==>  Preparing: UPDATE user SET code=?, userName=?, userPsw=?, userImg=?, userPhoneno=?, userAddress=?, userSex=? WHERE userId=? AND isDelete=0
==> Parameters: (String), qhy(String), 123456(String), https://img1.baidu.com/it/u=1415221871,1310171240&fm=253&fmt=auto&app=138&f=JPG?w=400&h=400(String), 15216477190(Long), 济南市(String), 0(Integer), 3(Long)
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@44996dab]
2022-04-09 19:26:13.055 ERROR 17424 --- [nio-8081-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: java.sql.SQLSyntaxErrorException: Unknown column 'userId' in 'where clause'
### The error may exist in com/example/mapper/UserMapper.java (best guess)
### The error may involve com.example.mapper.UserMapper.updateById-Inline
### The error occurred while setting parameters
### SQL: UPDATE user  SET code=?, userName=?, userPsw=?, userImg=?, userPhoneno=?, userAddress=?, userSex=?  WHERE userId=?  AND isDelete=0
### Cause: java.sql.SQLSyntaxErrorException: Unknown column 'userId' in 'where clause'

多次尝试无果只能来找大家了
  • 写回答

4条回答 默认 最新

  • a1767028198 2022-04-09 20:10
    关注

    Unknown column 'userId' in 'where clause'

    评论

报告相同问题?

问题事件

  • 创建了问题 4月9日

悬赏问题

  • ¥15 pcl运行在qt msvc2019环境运行效率低于visual studio 2019
  • ¥15 MAUI,Zxing扫码,华为手机没反应。可提高悬赏
  • ¥15 python运行报错 ModuleNotFoundError: No module named 'torch'
  • ¥100 华为手机私有App后台保活
  • ¥15 sqlserver中加密的密码字段查询问题
  • ¥20 有谁能看看我coe文件到底哪儿有问题吗?
  • ¥20 我的这个coe文件到底哪儿出问题了
  • ¥15 matlab使用自定义函数时一直报错输入参数过多
  • ¥15 设计一个温度闭环控制系统
  • ¥100 rtmpose姿态评估