• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate One to One Unidirectional

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi ,

To represent a One to One mapping in Database we need Primary and a Foreign key iconcepts both tables.

So there is relationship required beween these two tables

Then how does Hibernate one to one Unidirectional is possible

Thanks in advance .


 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can just map the association normally, but leave out the getters/make the getters private on the side you do not want direction from.



Mapping One to One Assocations with Hibernate

-Cameron McKenzie
 
Rex Tan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I just made sure both classes that are joined one-to-one are setup to have the same primary key so there is no foreign key needed,

 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!