Question is when an object with an assigned id was created and saved using org.springframework.orm.hibernate3.support.HibernateDaoSupport.getHibernateTemplate().saveOrUpdate(obj),
saveOrUpdate did update() instead of save(). why hibernate didn't know it is a new object and do save() ?
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0
Mapping documents:
Code:
<hibernate-mapping package="com.amg.brides.wedsimple.account.model">
<class name="com.amg.brides.wedsimple.account.model.WedSimpleAccountSync" table="wedsimple_sync_acct">
<cache usage="nonstrict-read-write" />
<id name="id" column="user_id" type="long" unsaved-value="0" />
<property name="sync" column="sync" type="string" not-null="false" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
org.springframework.orm.hibernate3.support.HibernateDaoSupport.getHibernateTemplate().saveOrUpdate(obj);
Full stack trace of any exception that occurs:
no error but no data is saved. When saveOrUpdate(new Object()) is called, hibernate did update by issuing a update statement. It should be calling save() with an insert sql.
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
When saveOrUpdate(new Object()) is called, hibernate did update by issuing a update statement. It should be calling save() with an insert sql.
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html