I hava two entities: PhisicalPerson (PP), JuredicalPerson (JP). And I want to create Phone object. JP has many phones and PP has many phones (one to many relation). So in Phone object I have to create 2 columns for this relations:
class Phone {
@JoinColumn(name="ppId",nullable=true)
@ManyToOne
public PhisicalPerson getPhisicalPerson() {...}
@JoinColumn(name="jpId",nullable=true)
@ManyToOne
public JuredicalPerson getJuredicalPerson() {...}
// number, city code, additional number and other fields
}
Is it right implementation? Or may be it's better to create different entities: PhisicalPersonPhone and JuredicalPersonPhone?