【异常】:Cause: java.sql.SQLSyntaxErrorException: Unknown column ‘udf1’ in ‘field list’… SQL: SELECT id,oper_id,btch_id,udf1, FROM scan_cyber Cause: java.sql.SQLSyntaxErrorException: Unknown column ‘udf1’ in ‘field list’;
,"message":"\r\n### Error querying database.Cause: java.sql.SQLSyntaxErrorException: Unknown column 'udf1' in 'field list'
The error may exist in com/yd/cyber/web/dao/ScanCyberDAO.java (best guess)
The error may involve defaultParameterMap
The error occurred while setting parameters
SQL: SELECT id,oper_id,btch_id,udf1, FROM scan_cyber
Cause: java.sql.SQLSyntaxErrorException: Unknown column 'udf1' in 'field list';
bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'udf1' in 'field list'","trace":"org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Unknown column 'udf1' in 'field list'
The error may exist in
【原因】: 我的第一反应是驼峰命名没有开启,但是去官网说默认是开启的,那么我们从上面的分析,可以看出是开启的没有问题,说 udf1
这个字段字表中不存在,我表中存的是udf_1
这个时候,其实这个时候问题已经找到了,就是驼峰命名是根据大写转化的,如果是数字的话,它是不会自动帮你转化的,就需要我们在VO
类中手动修改;
【解决方案】: 手动添加@TableField("udf_1")
即可解决
@TableField("udf_1")
private String udf1;