小编Pat*_*y31的帖子

SQL错误:1054,SQLState:42S22

大家好我正试图从我的数据库中检索一些数据,但我得到了

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'subject_id' in 'where clause'
Run Code Online (Sandbox Code Playgroud)

如果我检索同一个表的其他列,它可以工作.我正在使用spring和hibernate

这是我的控制器代码

@RequestMapping(value = "/getAnyQuestion", method = RequestMethod.GET)
public @ResponseBody
String getAnyQuestion(
        @RequestParam(value = "subId", required = true) Long subId,
        @RequestParam(value = "questionType", required = true) String questionType) {

    Question questionList = questionService.getAnyQuestion(subId,questionType);

    if (questionList != null) {
        questionId = questionList.getId();
        return questionList.getQuestionText();
    }

    return "";
}
Run Code Online (Sandbox Code Playgroud)

这是我的服务

 public Question getAnyQuestion(Long subId,String questionType) {             
    String query = "subject_id = " + subId +"  and "+ "questionType='" + questionType +"' and 1=1 order …
Run Code Online (Sandbox Code Playgroud)

mysql hibernate spring-mvc

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

hibernate ×1

mysql ×1

spring-mvc ×1