Serhat Türkman
Serhat Türkman

Reputation: 403

How can I design Jhipster JDL relationship for a simple Region > Country > State > City dropdowns

I couldn't figure out how to make relations between entities make them depended each other. Is jdl itself enough to have entities like below;

I've tried this;

entity Region {
    regionName String required
}

entity Country {
    countryName String required
}

entity State {
    stateName String required
}

entity City {
    cityName String required
}

entity Address {
    addressLine String required
}

relationship ManyToOne {
    Country{region(regionName)} to Region,
    State{country(countryName)} to Country,
    City{state(stateName)}  to State,
    Address{city(cityName)}  to City
}

paginate all with infinite-scroll
service all with serviceImpl

This jdl shows only it's parent. I want to create a new address entity with all parents up to region.

If I try to make relationships with all parents, all dropdowns are individual. You can select Asia > USA > Paris.

What is the right way to relate the address with Region, Country, State, City with correct dependencies?

Upvotes: 0

Views: 434

Answers (1)

Gaël Marziou
Gaël Marziou

Reputation: 16284

The JDL looks good to me, it's just that JHipster won't generate the client view with transitive relationships. You have to write it manually.

On server side, you can use DTOs to combine all data in one request. Add dto * with mapstruct to the bottom of your JDL and then edit generated mappers.

Upvotes: 1

Related Questions