-->
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: Querying for a subclass
PostPosted: Wed May 16, 2007 10:39 am 
Newbie

Joined: Fri Jan 12, 2007 12:25 pm
Posts: 6
Hi everyone!
I'm sorry, is there a way to query for a property type?
Here's my case:
I have 3 classes, mapped as

Code:
<hibernate-mapping>
    <class name="test.Main" table="main">
        <id name="id" column="id" type="long">
            <generator class="native"/>
        </id>

        <many-to-one
            name="other"
            class="test.Other"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="idother"
        />
    </class>
</hibernate-mapping>

Code:
<hibernate-mapping>
    <class name="test.Other" table="other">
        <id name="id" column="id" type="long">
            <generator class="native"/>
        </id>

        <joined-subclass name="test.Sub">
            <key column="id"/>
        </joined-subclass>
    </class>
</hibernate-mapping>


As you can see Main has a "other" property which can be a test.Other or a test.Sub.. Is there a way to express via Criteria a query like "get all the Mains with Subs"?

Hibernate version: 3.2.0

Many thanks for your attention!


Top
 Profile  
 
 Post subject: Querying for a subclass
PostPosted: Thu May 17, 2007 9:45 am 
Beginner
Beginner

Joined: Wed Apr 18, 2007 6:17 pm
Posts: 49
Location: Dominican Republic
hello joril, Try to use a Fetching to that association, you can find more about it in the hibernate reference on session 15.5

Regards,

if it help please rate the answer


Top
 Profile  
 
 Post subject: Re: Querying for a subclass
PostPosted: Fri May 18, 2007 4:52 am 
Newbie

Joined: Fri Jan 12, 2007 12:25 pm
Posts: 6
Session 15.5 is about using setFetchMode if I'm not mistaken, but I don't need to change _when_ the associated data is fetched, but _what_ is fetched.. I need to fetch only the entities with a certain subclass as associated data.
I'm sorry if I didn't explain it clearly :/ Thanks for your answer all the same :) (Maybe I misunderstood how FetchModes work though.. ^^; )


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 4:19 am 
Newbie

Joined: Fri Jan 12, 2007 12:25 pm
Posts: 6
Found it! Just query for "other.class" X-)
Thanks all the same!


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.