[英]Exception while fetching data (/getAccidentsForDriver) : null" from a GraphQL query in Postman
I'm using Spring MVC, with Hibernate and GraphQL.我正在使用 Spring MVC,以及 Hibernate 和 GraphQL。
I have 2 entity classes: Driver
and AccidentHistory
.我有 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
I want to return all the AccidentHistory
for an ID of a Driver
, but I cannot get it to work for the life of me and all I get is the exception which tells me close to nothing .我想返回所有
AccidentHistory
以获得Driver
的 ID,但我无法让它为我的一生工作,我得到的只是一个告诉我几乎没有的异常。
This is the HQL:这是 HQL:
"FROM AccidentHistory WHERE driver.personId = :id"
This is my GraphQL query:这是我的 GraphQL 查询:
query {
getAccidentsForDriver(id: 1) {
id
}
}
Why does this exception happen?为什么会发生这个异常?
After running the same code on another computer, we figured out that the project on my laptop wasn't building for some weird ass reason.在另一台计算机上运行相同的代码后,我们发现我笔记本电脑上的项目并没有因为一些奇怪的原因而构建。 The query is correct and there were no problems in general.
查询是正确的,一般没有问题。
I would just add that you need this line in your *.graphqls:我只想补充一点,您需要在 *.graphqls 中使用这一行:
getAccidentsForDriver(id: Int!): [AccidentHistory]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.