File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

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

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,

I agree. Here's the link:
subject: Hibernate One to One Unidirectional
It's not a secret anymore!