-->
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: Strange behavior when in cascade insert.
PostPosted: Wed Aug 17, 2005 12:02 pm 
A have to classes A and B.
They are connected via one to many relation.

I create new object a of type A:
A a = new A(); // currently not persistent

create new object b of type B:
B b = new B(); // currently not persistent

And say:
a.SetOfB.Add(b);

// class A contains
// <set name="SetOfB" inverse="false" lazy="true"
// cascade="save-update">
// <key column="a_id" />
// <one-to-many class="B" />
// </set>


then call: session.Save(a);

WHY the behavior of NH is:
1) insert in B with foreign key to A a_id = NULL
2) insert in A
3) update a_id in B with inserted a_id in A

instead of insert in A then insert in B?

In this situation I cannot make B.a_id not nullable :(((
And when I make it nullable I need more calls of Save(..)

First for a, then for b.
And it doesn't suits the concepts of my application.


Top
  
 
 Post subject: HB team help wanted!
PostPosted: Tue Jan 22, 2008 10:53 am 
Beginner
Beginner

Joined: Tue Jan 08, 2008 2:15 pm
Posts: 22
I am searching for a good explanation of that behavior to understand the "why" behind it.

That topic is the subject of a couple of unanswered forum messages and I think it deserves a good explanation - I have been looking for one in that forum, in the "best book" about Hibernate, Hibernate reference documentation and the web in general for a couple hours yesterday without success.

I have a couple URLs that I can share:

Those two are to show that the topic is still unanswered:

http://opensource.atlassian.com/projects/hibernate/browse/HHH-2280

http://forum.hibernate.org/viewtopic.php?t=957582&postdays=0&postorder=asc&highlight=foriegn+foreign+key+nullable&start=0

This one provides good insight, but what we need is a black and white sentence somewhere in Hibernate reference and a clear answer on the forum from the Hibernate team to support it:
http://www.cs.bham.ac.uk/~aps/syllabi/2006_2007/issws/h02/hibernate.html#one_to_many_unidir

Thanks in advance.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.