-->
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: SaveOrUpdate with assigned id - Newbie
PostPosted: Sat Oct 11, 2003 2:02 pm 
Newbie

Joined: Sat Oct 11, 2003 1:47 pm
Posts: 17
Sorry if its a stupid one, just beginning with hibernate.

My hbm.xml file has this for the id column
<id
name="name"
column="countername"
type="java.lang.String"
unsaved-value="null"
>
<generator class="assigned">
</generator>
</id>
Now when i save my object , i create an instance of the javabean and assign a value(not-null) to the primarkey("name" in this case). If i do a save() it works and my object gets persisted. If i do a saveorUpdate, it throws a
net.sf.hibernate.HibernateException: SQL update or deletion failed

as its trying to do an update on the code. I looked at the documentation and it says if the unsaved-value is null and my bean has a primarykey set to null, then the saveorupdate would save the record rather than updating it.

So what should i do if im having a generator of "assigned". Should i always use save to insert the record instead of saveOrUpdate?

Thanks
Raj


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 12, 2003 5:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
This is a FAQ question.


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.