Open MrHardcode opened 4 years ago
Yeah. Having a facade method like: "addHobbyToPerson" might've been nice (and probably easy to code), but hindsight is 20/20.
Something like (no errorhandling, no proper returnvalue etc, just the idea)
public void addHobbyToPerson(HobbyDTO_IN hobby, PersonDTO_IN person) {
// Guards
// Transform DTO into entity
// Check if hobby exists in database | em.find
// If it doesn't, persist it.
// If it does exist, make sure person doesn't have the hobby already.
// Put hobby on persons hobbylist
// Merge person
}
Make it possible to add multiple hobbies and phones when adding a person with everything