-->
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: Discriminator value not updated when updating row.
PostPosted: Thu Apr 10, 2008 12:29 am 
Newbie

Joined: Wed Apr 09, 2008 11:58 pm
Posts: 1
Hello All,
I have a hierarchy of classes that is mapped to a single table, and each of then is identified by the values given in discriminator-value in my hbm file.
This is the class level field called "status". What I would like to do is to insert a row with one subclass and update that row with another subclass.

I can update the row by doing the following:-

Code:
session.evict(obj_of_Subclass1);

Code:
session.update(obj_of_Subclass2);


by keeping their id fields to the same value. All relevent fields are updated except the discriminator field. Therefore, when I retrive the object for that row it returns object of type Subclass1 and not Subclass2.

Hibernate simply ignores the updation of this field. Does hibernate not allow this, or is there a configuration level change that I need to make in order to force the updation of the discriminator field?

My hibernate version, mapping document, etc


Hibernate version:3.0

Mapping documents:
Code:
<hibernate-mapping package="com.csam.wsc.enabling.core.ota">
      
      <class name="OTAAppState" table="wsc_app_lifecycle" discriminator-value="-1">
         <id name="id" column="id" type="long" access="field">
            <generator class="increment"></generator>
         </id>
         <discriminator column="status" type="int" />
         
         <property name="mobileNumber" column="mobilenumber" type="string" access="field"></property>
         <property name="vendor" column="vendor" type="string" access="field"></property>
         <property name="model" column="model" type="string" access="field"></property>   
         <property name="ipAddress" column="ipaddress" type="string" access="field"></property>
         <property name="appVersion" column="appversion" type="string" access="field"></property>
         <property name="tsEnrollment" column="tsenrollment" type="long" access="field"></property>
         <property name="tsDownload" column="tsdownload" type="long" access="field"></property>
         <property name="tsInstall" column="tsinstall" type="long" access="field"></property>
         <property name="tsUninstall" column="tsuninstall" type="long" access="field"></property>
         <property name="tsLastUpdate" column="tslastupdate" type="long" access="field"></property>
         <property name="installCode" column="installcode" type="int" access="field"></property>
         <property name="enrollmentChannel" column="enrollmentchannel" type="int" access="field"></property>
         
         <subclass name="OTAAppEnrollmentState" discriminator-value="1" dynamic-update="true" />
         <subclass name="OTAAppDownloadState" discriminator-value="2" dynamic-update="true"/>
         <subclass name="OTAAppInstallState" discriminator-value="3" dynamic-update="true"/>
         <subclass name="OTAAppUninstallState" discriminator-value="4" dynamic-update="true"/>
         
      </class>
      
   </hibernate-mapping>





Name and version of the database you are using:MySQL v5.0

The generated SQL (show_sql=true):Hibernate: update wsc_app_lifecycle set mobilenumber=?, vendor=?, model=?, ipaddress=?, appversion=?, tsenrollment=?, tsdownload=?, tsinstall=?, tsuninstall=?, tslastupdate=?, installcode=?, enrollmentchannel=? where id=?


Note:- In the above SQL, the "status" field which is the discriminator is nowhere to be seen. This is the field that is ignored.


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.