-->
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.  [ 1 post ] 
Author Message
 Post subject: saveOrUpdate question with subclassing/many-to-one
PostPosted: Thu Oct 25, 2007 12:34 pm 
Newbie

Joined: Fri Oct 12, 2007 5:09 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.