| Author |
Hibernate One to One Example
|
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
Hi
I am working on a simple Hibernate One to One Mapping Application .
For this i created two Tables Car and Registration as shown :
Car and Registration number are basically related to each other as one to one, that means for a single car, there could be at most a single registration number, and vice versa.
create table Car(car_name varchar2(20),car_model varchar2(50),primary key(car_name))
create table Registration(registration_number varchar(20),car_name varchar(20) not null, primary key(registration_number),unique(car_name))
Made car_name as Unique , so to have one to One mapping .
By IDE Reverseengineering i got these hbm files
This is for Car
This is for Registration :
Please tell me is this mapping correct because i have a seen a example in a site of One to One Hibernate where the author uses
<many-to-one> inside the hbm file .
Please let me know .
|
Save India From Corruption - Anna Hazare.
|
 |
xsunil kumar
Ranch Hand
Joined: Dec 14, 2009
Posts: 125
|
|
Your both hbm files are telling about individual entity. They are not telling about one to one relationship.You need to provide this in any one of your entity depends upon which entity you want to make it as souce. means which entity has foreign column.
|
 |
 |
|
|
subject: Hibernate One to One Example
|
|
|