• 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
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

@PrimaryKeyJoinColumn with bidirectional @OneToOne relationship and @Id

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to have a dependent object share the primary key of its parent.

I.E with tables
Table Parent
int PARENT_ID // primary key
String NAME

Table Child
int PARENT_ID // primary key, same as parent's primary key
String NAME

I read somewhere that hibernate allows the @Id annotation with a @OneToOne annotation (Is this only with a newer version of hibernate? I am running 3.2.4.sp1 (comes with jboss 4.2.3.))

So I have the following two entities:





But I get the following error from hibernate:



Any ideas? I this a hibernate problem (i.e. I need a newer version) or is there a flaw in the code?
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic