-->
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: unable to cascade save
PostPosted: Wed Jul 19, 2006 3:36 am 
Newbie

Joined: Wed Jul 19, 2006 3:24 am
Posts: 2
Need help with Hibernate? Read this first:

Hibernate version:3.13

Mapping documents:
<set name="bids"
cascade="save-update">
<key column="ITEM_ID"/>
<one-to-many class="Bid"/>
</set>

Code between sessionFactory.openSession() and
session.save(Item);
session.close():


Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):
insert into ITEM (NAME, ID) values (?, null);
update BID set NAME=? where ID=?
Debug level Hibernate log excerpt:

I want to insert "items" and it's "bids"
cascade="save-update" is also added. but hibernate generate "update BID" instead of "insert BID"
some body know why?

Thanks
Rick


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 19, 2006 4:01 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
If bid is getting updated it could be because you have set the id for bid already. Hibernate would then consider that it is already in the database and would therefore update instead of insert. If you are using generator class="assigned" for Bid, then you would need to use version or timestamp.


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