0

If I have a Entity class as such where a user can have multiple addresses:

@Entity
public class User {
    private String name;
    private List<Address> address;
}

@Entity
public class Address { 
    private String area;
    private String city;
}

Should the DTO exposed for the webservice contain Address object (like what User contains) or an AddressDTO object like this?

public class UserDTO {
    private String name;
    private List<AddressDTO> addressList;
 }

Where can I find example code using DTO objects that contain nested objects as such, where I can see best practices on how to populate those nested objects inside the main DTO? (I've googled ad nauseam but so far no examples with this scenario)

dataman
  • 123
  • 9

0 Answers0