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
|