Hello, hibernate newbie. I have a question with using saveOrUpdate with a subclass many-to-one. I invoke the method above and it inserts instead of update. Any insights or assistance is greatly appreciated. Using the unsaved-value attribute didn't seem to help (it helped in my other mappings).
I read the faq and forum and couldn't find a solution to what I am asking.
hibernate mapping file:
Code:
<hibernate-mapping>
<class name="com.somedomain.User"
table="isvod_user_favorites" batch-size="5">
<id name="uid" type="long" unsaved-value="0">
<column name="uid" precision="22" scale="0" />
<generator class="sequence">
<param name="sequence">user_seq</param>
</generator>
</id>
<discriminator type="string" insert="false">
<formula>
CASE
WHEN CONTENTTYPEID = 1 THEN 'TEMP'
WHEN CONTENTTYPEID = 2 THEN 'FULLTIME'
END
</formula>
</discriminator>
<property name="firstname" type="long">
<column name="firstname" precision="22" scale="0"
not-null="true" />
</property>
...
<subclass name="com.somedomain.TEMP"
discriminator-value="TEMP" >
<many-to-one name="temp"
class="com.somedomain.Temp"
fetch="select" column="user_type" />
</subclass>
</class>
</hibernate-mapping>
My Dao
Code:
public void saveOrUpdate(User transientInstance) {
getHibernateTemplate().saveOrUpdate(transientInstance);
log.debug("save successful");
}
Thanks!!!!
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp