[英]Spring Boot doesn't work custom JPA request
有这个代码:
@Query(value = "SELECT t FROM trainings t ORDER BY RANDOM() LIMIT 8", nativeQuery = true)
List<Training> findRandom();
收到此错误:
org.postgresql.util.PSQLException: The column name id was not found in this ResultSet.
执行此代码时:
System.out.println(trainingRepo.findRandom());
我的问题在哪里? 我该如何解决?
您不需要在此处使用“t”,因为它不是 JPQL,而是本机查询(您已设置nativeQuery = true
)
将查询替换为SELECT * FROM trainings ORDER BY RANDOM() LIMIT 8
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.