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.  [ 3 posts ] 
Author Message
 Post subject: Parent Child Relationship
PostPosted: Wed May 31, 2006 9:33 am 
Beginner
Beginner

Joined: Tue Feb 28, 2006 3:16 am
Posts: 28
Can anyone give pointer on the below mentioned scenario

1> I have Employee and Orders Table
2> EmployeeID is foreign key in Orders Table
3> I m creating Employee and at the same time Adding orders related to that.
4> I dont want to save first the employee object and then the orders object , i want to save all this as one single object.
5> I m getting the exception that can not insert null values for EmployeeId in Orders table.
6> I know that first i can save into Employee table and then into Orders table but i dont want to do that for some reason.

Can anybody throw some light on this issue.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 9:55 am 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
need to see your mapping files for the employee and orders entities. you should be able to map Employee.Orders as
Code:
cascade="save-update"
and call save session.Save(MyEmployeeObject) and get what you want.

-devon


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 9:03 pm 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
If the <key> column of a <one-to-many> association is declared NOT NULL, NHibernate may cause constraint violations when it creates or updates the association. To prevent this problem, you must use a bidirectional association with the many valued end (the set or bag) marked as inverse="true". See the discussion of bidirectional associations later in this chapter.

From http://www.hibernate.org/hib_docs/nhibe ... tions.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.