I'm trying to determine the best way to do a join between two entities with an additional attribute. To make things more complicated the additional attribute is a collection of objects.
An example of the situation might be something like a schedule of the days of the week people eat certain foods. So, you have three entities: Food, Day, and Person. You want to map that on Monday, Wednesday and Friday Joe Schmoe has Eggs. On Monday and Thursday Joe Schmoe has bacon.
The entities are faily simple and look like
Code:
class Food {
Long id;
String name;
}
class Day {
Long id;
String name;
}
class Person {
Long id;
String name;
}
Would you need to create an association class of some kind, like:
Code:
class PersonFoodSchedule {
Person person;
Food food;
Set days;
}
And then do any queries for food against the PersonFoodSchedule entity?
Any suggestions?
Thanks,
Rich