aspose file tools*
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
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate One to One Unidirectional