-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Join with extra attributes
PostPosted: Fri Oct 14, 2005 2:58 pm 
Newbie

Joined: Fri Oct 14, 2005 2:35 pm
Posts: 14
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


Top
 Profile  
 
 Post subject: three way join?
PostPosted: Mon Nov 21, 2005 3:55 pm 
Regular
Regular

Joined: Sat Nov 19, 2005 2:46 pm
Posts: 69
I've been doing searches looking for best practices for 3-way joins too.

At the moment I have a class representing a join of 2 of them, and then map that to the third. In your example it would be a PersonDay class, of which there would be 7 per person (Joe-Mon, Joe-Tue, Joe-Wed,...Fred-Sat, Fred-Sun,...Jim-Mon,...)

_________________
Stewart
London, UK


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.