• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate : Association

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic