-->
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.  [ 5 posts ] 
Author Message
 Post subject: via set tag parent is saved but unable to save childs
PostPosted: Wed Mar 10, 2004 5:37 pm 
Newbie

Joined: Fri Mar 05, 2004 2:52 am
Posts: 15
hi,
I am using hibernate 2.1 and sybase.this is my scenario


MovieLibrary
=============
ProgramID int
clientID int


composite key is (clientID,ProgramID)


mapping snippet for MovieLibrary is ---

<composite-id
name="movieLibraryPK"
class="MovieLibraryPK" >
<key-property name="clientID" column="clientID"/>
<key-property name="id" column="ProgramID"/>
</composite-id>

<set name="movies" cascade="all" inverse="true">
<key>

<column name="clientID" not-null="true" />
<column name="ProgramID" not-null="true" />
</key>
<one-to-many class="Movie" />
</set>



Movie
========

episodeID int
effectiveStartDate datetime
ProgramID int
clientID int

composite key is (episodeID,effectiveStartDate,clientID,ProgramID)

mapping snippet for Movie is ---

<composite-id
name="moviePK"
class="MoviePK" >
<key-property name="id" column="episodeID"/>
<key-property name="effectiveStartDate" column="effectiveStartDate"/>

<key-many-to-one name="movieLibrary" class="MovieLibrary">
<column name="clientID" not-null="true"/>
<column name="ProgramID" not-null="true"/>

</key-many-to-one>
</composite-id>


First of all is there any wrong with my complex mapping??
when I save session.save(movielibray);
movielibrary object is saved and I expect the childs "movies" also to be saved.But it is actually trying to update the movies and saying "batch update failed"count 0..

I didn't call saveOrUpdate() which I may call sometime later when some childs had to be inserted and some has to be updated.


Any help is greatly appreciated..
Thanks and Regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 5:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
read the doc. Cascadind always call saveOrUpdate. so set unsaved-value properly

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 5:53 am 
Newbie

Joined: Fri Mar 05, 2004 2:52 am
Posts: 15
thanks emmanuel!
I have kept unsaved-value="any" for the child.It inserted the parent i.e MovieLibrary and it even inserted the child i.e Movie(but in the Movie table column ProgramID is 0 ) It is not taking the ProgramID from the parent i.e MovieLibrary while inserting the child,Movie.

is this the problem because both my (MovieLibrary)parent and child (Movie)has composite keys??

Thanks and Regards for any help!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 2:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Does the appropriate entry (unsaved-value and composite-id) in the FAQ applies to your case ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2004 1:27 am 
Newbie

Joined: Fri Mar 05, 2004 2:52 am
Posts: 15
hi Emmanuel,
solved my problem, Thanks!
there was no problem with mapping,only with domain objects manipulation.

Regards


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