-->
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.  [ 2 posts ] 
Author Message
 Post subject: Discriminator setting id to determinator-value
PostPosted: Tue Nov 01, 2005 11:51 am 
Beginner
Beginner

Joined: Mon May 02, 2005 6:17 pm
Posts: 41
Hi all
I have a problem using inheritance with discriminator
here is the mapping
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
        Auto-generated mapping file from
        the hibernate.org cfg2hbm engine
-->
    <class name="model.DataType" table="DATATYPE" discriminator-value="0">
        <id name="dataTypeId" type="long" >
            <column name="DATATYPEID"  />
            <generator class="sequence" >
               <param name="sequence">DATATYPEID_sq</param>
            </generator>
        </id>
      <discriminator column="DATATYPETYPEID" type="long"/>
      
      <version name="beanVersion"
         column="version_"
         type="long" />
      
      <property name="name" >
            <column name="NAME" not-null="true" />
        </property>   
               
        <property name="description">
            <column name="DESCRIPTION" />
        </property>
      <property name="dataTypeId" insert="false" update="false">
            <column name="DATATYPETYPEID" />
        </property>   
      <subclass name="model.DataTypeEnumerated" discriminator-value="1">
         <join table="DataTypeEnumerated">
            <key column="DataTypeEnumeratedId" />
         </join>
      </subclass>
    </class>
</hibernate-mapping>

Both DataType and DataTypeEnumerated are not abstract classes and DataTypeEnumeratedis derived from DataType. Saving objects works fine but when i load an object i get exception:
identifier of instance model.DataType altered from X to 0
What am I doing wrong?

_________________
www.globalresearch.ca


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 12:10 pm 
Beginner
Beginner

Joined: Mon May 02, 2005 6:17 pm
Posts: 41
I found out what it was. My error off course. I mapped discriminator column to id property by mistake.
Copy paste can be a bitch

_________________
www.globalresearch.ca


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

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.