-->
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: Newbie question: Inserting objects with collections
PostPosted: Wed Jan 11, 2006 12:19 pm 
Newbie

Joined: Fri Jan 06, 2006 12:23 pm
Posts: 11
Hi, I have the following question:

I have a class "Persona" which has a collection of objects called "Direccion".

The thing is, when I create a Person object, then add the n Direccion objets, when I want that to be saved in the data base, I get the error that it cannot insert null in the PersonId field, in the Direccion table.

That's because the Person has just been inserted.
How do I have to tell nHibernate that that Direccion objects must be inserted with the PersonId that has just inserted?

Understand what I mean?

thanks!
Hope to be clear with the explanation.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 2:03 pm 
Regular
Regular

Joined: Tue Mar 15, 2005 12:38 pm
Posts: 73
Location: Bucharest
Post your mappings please.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 2:45 pm 
Newbie

Joined: Fri Jan 06, 2006 12:23 pm
Posts: 11
I discovered what I was doing wrong.
I wasn't setting the the Persona instance on the Direccion instance before doing the session.Save(_persona);
So, the direccion object, didn't know which PersonaId to use.

Thanks!


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.