Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate : Association

 
Bhavik Patel
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one master table lets say staff with staffID and 6 other tables are using the staffID along with their data.. Does that mean that my staff table mapping will have <set> ( assuming theres one to many relation ) element for all 6 tables ...How do i decide whether it hsould be bi directional asociation or uni direction association and what i have to do in mappings to ensure its implementing association properly .. please give me an example to clear this doubt as i am new to hibernate and this associations confuse me a lot...

Thanks
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, think of each one as a different association. You have one tables that is a one to 6 different many tables. So you would probably have 6 different sets.

In terms of directional, it is all about your object model, not about the database model. Do you want to be able to go in both directions? If you do then you map it bi-directional, if you only want to have the one object and be able to get the many objects, but don't need to go from a many object to its one side, then make it uni-directional.

Each one with a <set>, or <list> or, <map> and <one-to-many> tags to declare the mapping. Check out www.jboss.org and go to the hibernate wiki, at the bottom are tutorials, there is one near the bottom that is really good.

Good Luck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic