What do you mean in two ways?
If you mean that you want to have access to stylists from your salon object in code, then you will need something like this:
public class Salon extends Model { @ManyToMany @JoinTable(name = "salon_stylist", ...) public List<Stylist> stylists; ... }
And your Stylist object might look like this:
public class Stylist extends Model { @ManyToMany @JoinTable(name = "salon_stylist", ...) public List<Salon> salons; ... }
Then your yml might look like this:
Salon(salon1): name: salon1 city: singapore country: singapore Salon(salon2): name: salon2 city: tokyo country: japan Stylist(stylist1): firstName: stylist1 lastName: stylist1 title: Stylist 1 price: $100 salons: - salon1 - salon2
Just saying that stylist1 belongs to salon1, and salon2 should be enough in yml (that is, you do not need to declare the same in two yal salon entries).
source share