吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2783|回复: 8
收起左侧

[已解决] mybatis-plus报错:SQL语法错误 [错因是实体类有和mysql关键字相同字段]

[复制链接]
ing 发表于 2022-1-24 16:46
本帖最后由 ing 于 2022-1-24 17:13 编辑

1捕获.PNG


这是报错类的代码,有写new Page<>(startPage, pageSize); 理想不应该会出现这种错误,报错位置已打上断点标记
2捕获.PNG


这个类使用到的mapper
3捕获.PNG


前端
4捕获.PNG


无语的是,我有一个功能相同的实现类却没有报错
6捕获.PNG


7.PNG
7.PNG


完整报错(已忽略报错完整)
[Java] 纯文本查看 复制代码
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.baomidou.mybatisplus.core.toolkit.SetAccessibleAction (file:/C:/Users/admin/.m2/repository/com/baomidou/mybatis-plus-core/3.4.3/mybatis-plus-core-3.4.3.jar) to field java.lang.invoke.SerializedLambda.capturingClass
WARNING: Please consider reporting this to the maintainers of com.baomidou.mybatisplus.core.toolkit.SetAccessibleAction
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
org.springframework.jdbc.BadSqlGrammarException: 
### Error querying 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 ',rooms,households  FROM c_building LIMIT 10' at line 1
### The error may exist in com/hstc/dao/mapper/BuildingMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT  id,unit_code,left,rooms,households  FROM c_building LIMIT ?
### 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 ',rooms,households  FROM c_building LIMIT 10' at line 1
; bad SQL grammar []; nested exception is 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 ',rooms,households  FROM c_building LIMIT 10' at line 1
        at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:235)

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| ing 发表于 2022-1-24 17:12
报错是因为实体类有和mysql关键字相同字段
捕获.PNG
解决方法
@TableField("`left`")
private Integer left;
chen299 发表于 2022-1-24 17:03
在上面不是已经可以看到sql语句了吗,检查一下是那个字段没有
永恒陌 发表于 2022-1-24 17:07
异常:sql语法错误
截图一大堆。 就是不截完整的数据库结构和sql语句。
黄hsir 发表于 2022-1-24 17:16
看看实体类和表结构啊,设置下吧sql输出出来,你这截了几个无关紧要的图
Vvvvvoid 发表于 2022-1-24 17:17
字段名跟MySQL冲突了吧
isPasser 发表于 2022-1-24 17:54
关键字做字段名&#128077;
alterempty 发表于 2022-1-24 18:20
@TableField("`left`")
chengxuyuan01 发表于 2022-1-25 15:46
sql异常一般有字段类型错误,关键字错误,关键字重复,分隔符错误
你用的是mybatis-plus封装的查询方法,关键字和分隔符错误可以排除,
具体查下是不是类型错误或者类中的属性和表中是否一一对应。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-9 23:54

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表