CSDN停更,所有博客已搬至 rainofshadow.top 个人服务器。 最新文章,移至 https://rainofshadow.top/
前一篇写到了mycat的分表的操作,本以为在工程中只修改application.yml中mycat的配置文件,原来的代码不做修改即可。直到最近测试时,才发现问题。
通过postman传入problem的参数,通过mapper修改的数据的代码
@Override
public void updateProblemById(Problem p) {
Example example = new Example(Problem.class);
example.createCriteria().andEqualTo("id",p.getId());
problemMapper.updateByPrimaryKey(p);
}
然后报错
org.springframework.jdbc.BadSqlGrammarException:
### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SQL AST nodes type mismatch!
### The error may involve com.recommend.common.mapper.ProblemMapper.updateByPrimaryKey-Inline
### The error occurred while setting parameters
### SQL: UPDATE r_problem SET id = id,content = ?,ans = ?,type = ?,cid = ?,ques_difficult = ?,ques_options = ?,score = ?,position_id = ?,image = ? WHERE id = ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SQL AST nodes type mismatch!
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SQL AST nodes type mismatch!
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:234)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy151.update(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:294)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy180.updateByPrimaryKey(Unknown Source)
at com.recommend.service.admin.service.impl.ManagerWrittenExaminationServiceImpl.updateProblemById(ManagerWrittenExaminationServiceImpl.java:48)
at com.recommend.service.admin.controller.ManagerWrittenExaminationController.updateProblemById(Manage