• 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 questions

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Does Hibernate always require a "join table" to create association between two tables ? Is it possible to use the foreign key constraint in the database instead of having a separate join table ?

Also if I were creating a data model, are there special considerations that I should keep in mind when I know that Hibernate will be using the data model ?

Thanks,

J.C
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depending on your association/relationship, a join table is not required. It would be required in a many to many scenario, but not many to one or one to many.

There are a few things to bear in mind when writing java classes that will be mapped with Hibernate to a relational database. You generally need a no args constructor (although due to Hibernate's trickery) this doesnt need to be public.

You will also need to think about identity of hibernate persisted objects. This may mean adding an indentity property that you otherwise wouldnt need to access.

Hope this helps.

Rosco
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic