-->
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: HQL path for discriminator subclass property?
PostPosted: Thu Aug 12, 2010 2:37 pm 
Newbie

Joined: Thu Aug 12, 2010 2:20 pm
Posts: 1
I have a discriminator class with two subclasses in their own tables. They don't share property/columns names as they store different information. If I had the two subclasses and one had a propery status, but the other didn't, can I add a WHERE clause for that property?

With a mapping like this:
Code:
<hibernate-mapping>
   <class name="com.myClass" table="classDiscriminatorTable" lazy="false" discriminator-value="0">
      <id name="id" column="parentId">
         <generator class="foreign">
            <param name="property">lead</param>
         </generator>
      </id>

      <discriminator column="classType" type="integer"/>

      <subclass name="com.myClass.subClassA" discriminator-value="1">
         <join table="classB">
            <key column="parentId" />
            <property name="response"/>
         </join>
      </subclass>

      <subclass name="com.myClass.subClassB" discriminator-value="2">
         <join table="classB">
            <key column="parentId" />
            <property name="status"/>
         </join>
      </subclass>
   </class>
</hibernate-mapping>

Can I create a HQL query that uses myClass.subClassB.status:
Code:
String hql = "FROM Parent INNER JOIN FETCH myClass as myClass  WHERE myClass.class = com.myClass.subClassB AND myClass.status = :status";

Thanks!


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.