I'm using JDL (JHipster 5.8.1) to define my domain model with DTO option:
entity Event {
title String maxlength(128) required,
bannerUrl String maxlength(256) required,
summary String maxlength(256) required
}
entity Tag {
name String maxlength(64) required
}
entity Team {
title String maxlength(128) required,
description TextBlob
}
relationship ManyToMany {
Event{tags} to Tag{events}
}
relationship OneToMany {
Event{teams} to Team{event required}
}
relationship ManyToOne {
Event{city} to City{events}
}
dto * with mapstruct
I tried to define Events which contains Multiple reusable tags and multiple Teams. The intetions is to make API generate composite JSON which contains all Tags and all Teams inside requiested Event (to avoid N+1 problem in REST)
I expected to get bidirectional relations between Tag <-> Event and Team <-> Event. For ManyToMany relations it is true: I see getter for TagDTO inside EventDTO. But for OneToMany (also ManyToOne) I doesn't see any getter inside EventDTO an have eventId getter inside Team:
public class EventDTO implements Serializable {
private Long id;
@NotNull
@Size(max = 128)
private String title;
@NotNull
@Size(max = 256)
private String bannerUrl;
@NotNull
@Size(max = 256)
private String summary;
private Long cityId;
private Set<TagDTO> tags = new HashSet<>();
The code generated without dto * with mapstruct
line produced expected JSON with all child entities if eagerload=true, but this approch could cause security problems.
Is it possible to correct my JDL to produce childEntity-like DTOs but not childId-like DTOs?