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

reverse engineering a one to one relationship

 
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys : I have a database where

table a references table b, and the reference is unique, i.e.



Now, I've reverse engineered the dao code in hibernate but for some reason, I have the following in my API ...



Anyways. This is really bothering me, because it complicates the API unnecessarily.

Since a unique column referencing a table key that is also unique, this should always be a one to one relationship, right ?

How can you clue in hibernate to do a one to one instead of a set? (Yes I've defined ssid as unique in the database).
 
Ranch Hand
Posts: 265
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jay,

What tool are you using to do the reverse engineering?

The table structure you have defined would actually be one-to-many; you haven't defined any reverse restriction that there's a unique constraint on person (name + ssid). This is assuming that by stating you've defined ssid as unique, you mean as the primary key of ref_ssid. If you mean in the person table, then that should be sufficient.

You may want to double check your FK was correctly defined. If you did it in the order you described, it would have failed, because you can't add a FK to a table/field that doesn't yet exist. i.e., try:



But not knowing the full details or what tool your using, these are just best guesses.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup - I definetly had the reverse constraint for uniquenss in there.... Im using the hibernate reverse engineering tool in the jboss ide.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic