• 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

Bidirectional @OneToOne with JoinTable

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 2 entities :Customer & Address.

With @OneToOne and @JoinTable Customer.java looks like this:



Now Address.java



When I try to persist a customer I get the following stack-trace:



I have tried this change in Address entity:



with no effect. Surely this could be done without using JoinTable.But I want to do it this way for academic interest.Is it possibe?
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assume that this design is part of a learning experience. However, if this is a production design then you should ask yourself, Does an address really need to point back to its owner?
 
Subhendu Mahanta
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ron.
You are correct that this is part of a learning experience.There is no need for address to point back to customer.Let's say there are 2 entities A & B which have a bi-directional association. In that case I think shared primary key will be the preferred technique.
 
Subhendu Mahanta
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wanted to mean "Thanks Ran".Sorry for the typo.
 
Honk if you love justice! And honk twice for tiny ads!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic