首页 > 解决方案 > jHipster, generated DTO does not contain related Child DTOs

问题描述

Use case: I would like to call a top level (parent) DTO that returns nested children DTO objects.

Example entities:

entity Person {
    firstName String
    lastName String
}

entity Dog {
    petName String
}

relationship OneToMany {
    Person{dog} to Dog{person required}
}

The generated PersonDTO does not include the DogDTO. I would like it to return the following:

{
    "id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "dogs": 
            [
                {
                    "id": 1                    
                    "petName": "Fido"
                },
                {
                    "id": 2
                    "petName": "Spot"
                }
            ]   
}

Thank you

标签: jhipster

解决方案


推荐阅读