-->
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: Mapping association to subclass, strange behavior?
PostPosted: Thu Jul 27, 2006 5:24 am 
Newbie

Joined: Wed Jun 28, 2006 5:06 am
Posts: 4
Location: The Netherlands
Maybe I do something wrong but I have a problem. I have a table with the following columns

id(number), fk_id(number), clob(clob), discriminator(string).

My subclasses are mapped as the following

Code:
<class abstract="true" name="Clob"  table="efx_clob">   
   <id name="id" unsaved-value="-1" column="clob_id">
      <generator class="sequence">
         <param name="sequence">efxs_clob</param>
      </generator>
   </id>

   <discriminator column="discriminator" type="string" />

   <property
       name="clob"
       column="clob_data"
       type="clob"
       insert="false"
       update="false">
   </property>
   
   <subclass discriminator-value="CLOB1" name="ClobTypeOne"/>
   <subclass discriminator-value="CLOB2" name="ClobTypeTwo"/>
</class>


In another class I have a mapping to a set of ClobTypeTwo objects, however this also contains ClobTypeOne objects?! Resulting in WrongClassExceptions. The mapping

Code:
<set
   name="clobs"
   cascade="all-delete-orphan"
   inverse="false"
   lazy="false">
   <key column="fk_id"/>
   <one-to-many class="ClobTypeTwo" />
</set>


If I look at the query generated it is like

Code:
select {all mapped fiels} from clobs where fk_id=?


However I would have suspected it to be (Which is what is happening when I get the class directely with get(ClobTypeTwo.class, id)).

Code:
select {all mapped fiels} from clobs where fk_id=? and discriminator='CLOB2'


For now I have solved it by including a where clause in the set, however I don't think that that should be necessary. Any more light, suggestions for this situation? Or maybe a bit more indept explaination?

For the record we are using hibernate 3.1.3, JDK, 1.4.2_05 on windows machines.


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.