-->
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.  [ 4 posts ] 
Author Message
 Post subject: joined-subclass question with the "class" property
PostPosted: Tue Feb 17, 2004 12:48 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 2:14 pm
Posts: 40
Location: Atlanta, GA, USA
I have an AbstractFish object with two joined subclasses Shark and Trout. See the mapping below. (Note: these are just test classes. :)

When I run the following HQL query....
from AbstractFish f where f.id = 1
...everything works out fine, so I am fairly confident that my mappings are correct.

When I run this HQL query...
from AbstractFish f where f.class = com.matrix.bo.Shark
nothing is returned. I do not get an error, but my object is not returned and I know I have data, because I can load the object using a different query.

I have a similar example that uses the table-per-hierarchy with discriminators and the "class" attribute works fine with similar queries.

Question) Does the special attribute "class" in the hibernate query language not work for joined-subclass?


Code:
<hibernate-mapping>
    <class
        name="com.matrix.bo.AbstractFish"
        table="Fish"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="Fish_ID"
            type="int"
            unsaved-value="0"
        >
            <generator class="native">
            </generator>
        </id>

        <property
            name="color"
            type="string"
            update="true"
            insert="true"
            column="Color"
            length="70"
            not-null="true"
            unique="false"
        />

        <property
            name="name"
            type="string"
            update="true"
            insert="true"
            column="Name"
            length="50"
            not-null="true"
            unique="false"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-AbstractFish.xml
            containing the additional properties and place it in your merge dir.
        -->

        <joined-subclass
            name="com.matrix.bo.Shark"
            table="Shark"
            dynamic-update="false"
            dynamic-insert="false"
        >
        <key
            column="Fish_ID"
        />
        <property
            name="toothSize"
            type="string"
            update="true"
            insert="true"
            column="ToothSize"
            length="35"
            not-null="true"
            unique="false"
        />

        </joined-subclass>
        <joined-subclass
            name="com.matrix.bo.Trout"
            table="Trout"
            dynamic-update="false"
            dynamic-insert="false"
        >
        <key
            column="Fish_ID"
        />
        <property
            name="smell"
            type="string"
            update="true"
            insert="true"
            column="Smell"
            length="40"
            not-null="true"
            unique="false"
        />

        </joined-subclass>

    </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2004 12:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I think it works only for normal subclasses so far.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2004 2:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
.class is a keyword to retrieve the discriminator

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2004 2:39 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 2:14 pm
Posts: 40
Location: Atlanta, GA, USA
Ok. Thanks for the quick responses!


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