-->
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.  [ 3 posts ] 
Author Message
 Post subject: Polymorphism doesn't run
PostPosted: Thu Apr 26, 2007 12:41 pm 
Newbie

Joined: Thu Apr 26, 2007 12:29 pm
Posts: 2
Hi all,

I'm trying to run polymorphism with Hibernate and it doesn't run. I've two tables: QUESTION (with id, name and question_type_id) and QUESTION_TYPE (with id and name).

Question has a foerign key to QUESTION. For one QUESTION_TYPE. named "Multivaluated", I want to define a MultivaluatedQuestion class which includes a set of other objects of class Possibilities.

I'm defining the polymorphism in this way:

Code:
    <class name="...Question" table="QUESTION" schema="CPOL" discriminator-value="0">
<id...>
        <discriminator type="integer" >
         <formula>
            <!-- CASE WHEN (SELECT type.NAME FROM QUESTION q,QUESTION_TYPE type WHERE q.QUESTION_TYPE_ID = type.ID) IN ('Multivaluated') THEN 1 ELSE 0 END -->
            1
         </formula>
        </discriminator>
      <subclass name="...MultiValuatedQuestion" discriminator-value="1">
           <set name="posibilities" inverse="true">
               <key>
                   <column name="QUESTION_ID" precision="22" scale="0" not-null="true" />
               </key>
               <one-to-many class="...Posibility" />
           </set>
      </subclass>
...


When trying to load a Question with a Question_type with name 'Multivaluated' I'm always getting instances of Question in spite of MultivaluatedQuestion. Even with a simple formula that forces to be Multivaluated it returns instances of Question.

What am I doing wrong?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 11:40 pm 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi djise,

I am bit confuse what is 1 at the last of formula

<formula>
<!-- CASE WHEN (SELECT type.NAME FROM QUESTION q,QUESTION_TYPE type WHERE q.QUESTION_TYPE_ID = type.ID) IN ('Multivaluated') THEN 1 ELSE 0 END -->
1 </formula>

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 27, 2007 2:54 am 
Newbie

Joined: Thu Apr 26, 2007 12:29 pm
Posts: 2
It's a test... I wanted to force the formula to value 1, and force the objects to be of class MultivaluatedQuestion (discriminator-value="1").


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.