These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: One To Many Relationship
PostPosted: Tue Jul 07, 2009 11:40 pm 
Newbie

Joined: Wed Jun 03, 2009 2:21 am
Posts: 5
Hi,

I have a requirement where i have to establish a one-to-one relationship between tables
CUSTOMER<-1--1->CORPORATE_EMPLOYEE<1--1>LOGIN_CREDENTIALS table

I tried with <one-to-one> in Customer.hbm and <many to one> with "unique=true" in CorporateEmployee.hbm as both the table are related via Foreigh key. CUSTOMER.CUSTOMER_ID is present as foreign key in CORPORATE_EMPLOYEE table
CORPORATE_EMPLOYEE.EMPLOYEE_ID is present in LOGIN_CREDENTIALS as a foreign key.

So If i want to save a Customer object, Is there a way that i say save(customer) which automatically saves CorporateEmployee and LoginCredentials as well ?

Iam new to hibernate and struggling with this issue for the past few days. If any body has worked on this part can you please help ? Please bear with me if this question sounds so trivial.

Regards,


Top
 Profile  
 
 Post subject: Re: One To Many Relationship
PostPosted: Wed Jul 08, 2009 7:38 am 
Regular
Regular

Joined: Wed Jun 20, 2007 1:53 am
Posts: 75
use cascade='save-update' in many-to-one which links CorporateEmployee in Customer hbm.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.