我正在用Spring Boot开发一个应用程序。使用JPA时,出现SQL语法错误。
public interface ReservoirRepository extends CrudRepository<Reservoir, Integer> {
@Query(value = "From reservoir where patientID = ?1", nativeQuery = true)
public List<Reservoir> findByPatientId(Integer patientId);
}
这是MySQL表和数据
错误说明是这样的
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 'From reservoir where patientID = 1' at line 1
请帮助我,我没有在这里出什么问题。谢谢 :)
最佳答案
编写完整的sql命令,作为其本机查询。喜欢
@Query(值=“ SELECT * FROM水库资源,其中res.patientID =?1”,nativeQuery = true)