I have two distinct table
@Data
public class Person {
@id
Long id;
String name;
Long aCommonId;
}
And another table:
@Data
public class PhoneNumber {
@id
Long id;
String phoneNumber;
Long aCommonId;
}
I’m trying with projection to have a DTO like this:
@Data
public class DTO {
Person person;
List<PhoneNumber> phoneNumbers;
}
I have a Jpa Query that retrieve correctly the data based on “aCommonId” the data (there are no “officially” relationship between tables) but hibernate instead of putting multiple PhoneNumber in the List, is returning a List of DTO with the same person and a List with one PhoneNumber.
How to tell Spring JPA to put PhoneNumber in the list?