I have a Person entity. The Person entity has a list of PhoneNumber
entities (as shown below).
If I want to add a phone number to a person's list of phone numbers,
what is the most efficient/recommended
way of doing this ?
For example is it ok to do something like that in PersonEntity:
PhoneNumberEntity phoneNumber = new PhoneNumberEntity("1234567890");
this.getPhoneNumbers.add(phoneNumber);
phoneNumber.setPerson(this);
Is there any other (better or recommended) way of adding a phone number
in terms of
performance or in terms of other considerations ?
Thanks,
Gul
@Entity
public class PersonEntity implements Serializable {
@OneToMany
private List<PhoneNumberEntity> phoneNumbers;
...
}