• 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Problem in <one-to-one> relation mapping

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi frnds...i got a prob. i am posting everything what i wrote....In database there are two tables Person and Car

Person table(id,name,address)
Car table(id,brand,person_id)....person_id is FK from person table.


Person Class:



Car Class:


Car Mapping file:



Person Mapping file:


Connection class where i created session and all others.




here i created one-to-one mapping using <many-to-one> relation by putting "unique" attribute to true in Person mapping file. And when i execute it i got an error which is shown below:


Frnds please help me in clearing this mapping relation i'm very confused with this. Waiting for your valuable replies. If i did any mistake in the above code. Please correct me...

Thank in advance.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since the CAR table has the PERSON_ID column (I find this a little unusual though), I am assuming the Car object is pointing to a Person object. In that case your Car class should be



and your car mapping should be




If you truly really want a bidirectional relationship and wish a pointer from person to car, the person mapping should be



 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic