【发布时间】:2021-04-05 19:02:53
【问题描述】:
我的StudentRepository 中有这个查询,我想查询中有一些错误:
@Query("SELECT Student.groupId FROM Student WHERE Student.studentLogin=?1")
Integer getGroupIdByStudentLogin(String studentLogin);
但仍然找不到正确重写的解决方案。
【问题讨论】:
我的StudentRepository 中有这个查询,我想查询中有一些错误:
@Query("SELECT Student.groupId FROM Student WHERE Student.studentLogin=?1")
Integer getGroupIdByStudentLogin(String studentLogin);
但仍然找不到正确重写的解决方案。
【问题讨论】:
正确的查询语法是:
@Query("SELECT s.groupId FROM Student s WHERE s.studentLogin=?1")
Integer getGroupIdByStudentLogin(String studentLogin);
请参阅The Java Persistence Query Language 了解更多信息。
【讨论】: