![](/img/trans.png)
[英]Spring Data JPA, error while sending data to postman from Rest Controller, Nested exception
[英]Exception while fetching data (/getAccidentsForDriver) : null" from a GraphQL query in Postman
我正在使用 Spring MVC,以及 Hibernate 和 GraphQL。
我有 2 个实体类: Driver
和AccidentHistory
。
public class Driver implements java.io.Serializable {
private int personId;
private Set<AccidentHistory> accidentHistories = new HashSet<AccidentHistory>(0);
//Rest of the class
public class AccidentHistory implements java.io.Serializable {
private Integer id;
private Driver driver;
//Rest of the class
我想返回所有AccidentHistory
以获得Driver
的 ID,但我无法让它为我的一生工作,我得到的只是一个告诉我几乎没有的异常。
这是 HQL:
"FROM AccidentHistory WHERE driver.personId = :id"
这是我的 GraphQL 查询:
query {
getAccidentsForDriver(id: 1) {
id
}
}
为什么会发生这个异常?
在另一台计算机上运行相同的代码后,我们发现我笔记本电脑上的项目并没有因为一些奇怪的原因而构建。 查询是正确的,一般没有问题。
我只想补充一点,您需要在 *.graphqls 中使用这一行:
getAccidentsForDriver(id: Int!): [AccidentHistory]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.