I'm new to mapstruct and I have a couple questions that I could not find an answer for.
I have an Entity1 (object) that has a Many2Many relationship with the Entity2. In this case, my Entity1DTO can bring all the data (Swagger) from Entity1 using a Set:
private Set<Entity2DTO> appusers = new HashSet<>();
That Set has all the information about all the Entity2DTO objects.
Then, I have another Entity3 with a relation (One2Many) with Entity1. When I want to get all the same information with Entity3 (One2Many) it only brings the ID of Entity3 and the rest of the attributes are null.
private Entity3DTO entity3;
Mapper:
@Mapping(target = "entity3", source = "entity3", qualifiedByName = "id")
Entity3DTO toDto(Entity3 s);
If I change the mapper and include, not only the id, but the other attributes (it will work), but I want to ask if there is an easier or more direct way to change the DTO or the mapper to bring the rest of the data, is there any?
And... Why it brings all data in the case of the Set, but not in the other case?
MapStruct documentation is not clear enough, so if you have any other examples with Jhipster that would be great.
Thanks for your help.