-->
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.  [ 7 posts ] 
Author Message
 Post subject: Working of :: Cascaded save or update
PostPosted: Mon Oct 13, 2003 2:47 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 8:27 am
Posts: 36
Team,

Is this how the cascaded save or update works.

(Assume that the abjects are new at it is all save).

Hibernate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2003 8:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Read the parent child document on the wiki. It should provide some pointers.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2003 9:38 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 8:27 am
Posts: 36
By wiki do you mean http://www.hibernate.org/37.html

If not, Please do forgive my ignorence and point me to the right place.

Also i have gone through the parent- child notes in the document (PDF version) and that does not give me enough insight as to how exactly it does work.

Regards
Suchak Jani


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2003 9:40 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The reference documentation contains the "parent/child" chapter theses days, not the wiki. And is, with the other 100 pages of reference documentation, enough to understand this issue.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 14, 2003 4:00 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 8:27 am
Posts: 36
Christian,

I would really appreciate if you would point me to the right place for answering this question.

Why does hibernate do this (internally)
1. Save parent entity
2. Save child entity (with relating column as null)
3. Update the child setting the relating column to the parent


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 14, 2003 4:13 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Because you forgot to set inverse="true" on the "many" end of your association. Read the parent/child mapping chapter, twice if neccessary.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 14, 2003 10:09 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 8:27 am
Posts: 36
Quote:
Because you forgot to set inverse="true" on the "many" end of your association. Read the parent/child mapping chapter, twice if neccessary.


Yes Christian,

That must is true, however in my case one Child can have many Parents.

Here is what i mean and i guess i will give you a concrete example.

There is a Address table, which has a Owner_Type and a Owner_ID. Now a Company could have Adresses, a Corporation could have Addresses, a Bank could have Addresses.

So for Company type Address.Owner_Type="Company" and Address.Owner_ID="Company_ID"
but for Corporation type Address.Owner_Type="Corporation " and Address.Owner_ID="Corporation _ID"

In other words Company has "one to many" with Address, but Address is not a "many to one" with Company as Address has "many to one's" with Corporation, Bank etc also.

However when saving, let's say a Company, for which Hibernate does have a one to many with Address.owner_ID related by Company_ID, why should hibernate do it in three steps , the second step being save address with Owner ID as null.

By the way i did read the document and i think i am clear on what it explains, however this problem of mine, that i describe above, is different and i hope it is not unique.

I still think that if i have a inverse on the "one to many" side that Hibernate should do this ::::
1. Save parent entity
2. Save child entity with relating column as parent


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