• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate questions

 
James Clarke
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • 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
 
Rosco Duncan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic