This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes Hibernate One to One Unidirectional Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate One to One Unidirectional" Watch "Hibernate One to One Unidirectional" New topic
Author

Hibernate One to One Unidirectional

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234


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 .



Save India From Corruption - Anna Hazare.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

Joined: Mar 26, 2009
Posts: 8
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,



SCJP 1.6, SCWCD 1.5, MCTS, MCT
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate One to One Unidirectional