• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

composite key

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering whether its a good idea to have a composite key in our table.
Our case is like this
A voyage can have a lot of dailyCargoReports associated to it.
Now the dailyCargoReport table can have 2 columns
voyage_id <pk>
sr_no <pk>
which represents the composite key
OR
one id column represnting the PK and one FK to voyage_id

which is a better way to go for from hibernate perspective.

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
Hibernate can map both cases, now if you are in control of the database schema, I always use a surrogate pk key which is just ids.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic