This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

reverse engineering a one to one relationship  RSS feed

 
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • 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 Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!