简体   繁体   English

从 Postman 中的 GraphQL 查询获取数据时出现异常 (/getAccidentsForDriver): null"

[英]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 个实体类: DriverAccidentHistory

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.

相关问题 Spring Data JPA, error while sending data to postman from Rest Controller, Nested exception - Spring Data JPA, error while sending data to postman from Rest Controller, Nested exception 从数据库中获取数据时解密 - decryption while fetching data from database HQL查询,用于从表中获取数据 - HQL query for fetching data from a table 为什么在以多对一关系获取数据时执行额外的查询? - Why extra query executed while fetching data in Many to One relationship? 从投影列表获取子实体时出现间歇性惰性异常 - Intermittent Lazy exception while fetching the child entities from the projectionlist 使用数据 JPA 在 Spring Boot 中通过邮递员插入记录时出现空指针异常 - Null Pointer Exception on insert record through postman in Spring Boot using Data JPA 从 spring 中的多个表中获取数据的自定义查询 - Custom Query for fetching data from multiple tables in spring 用于从spring Data Jpa中的多个表中获取数据的自定义查询 - Custom Query for fetching data from multiple tables in spring Data Jpa 从休眠获取数据时发生java.lang.ClassCastException - java.lang.ClassCastException while fetching data from hibernate 在迭代器上使用 next() 时出现异常,在使用 hql 查询获取数据后,即使数据存在 - Getting Exception when used next() on iterator, after fetching data with hql query even though data is present
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM