-->
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: restricting finding objects to just that class
PostPosted: Wed Dec 08, 2004 8:05 pm 
Newbie

Joined: Wed Dec 08, 2004 7:07 pm
Posts: 2
So in all the documentation and examples, i've seen that you can do a find with a hql clause
"from myClass" and it gets all inherited objects as well (very cool).
But lets say i have two classes
myClass and
myInherited extends myClass

And in a particlar case i ONLY want objects of type myClass and NO objects of type myInherited. I have searched through the internet, the documentation and a couple of books, but i can't see how to do that.

I'm sure i'm missing something painfully obvious here :(


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 8:46 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:57 am
Posts: 33
Location: Alpharetta, Georgia
Are you using table-per-class hierarchy or joined-subclasses?

If you know for sure you only want the subclass, specify it: com.blah.MyInherited.class
in your finds, queries, criteria


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 8:48 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:57 am
Posts: 33
Location: Alpharetta, Georgia
I'm sorry, I misread - you're looking for only the parent and not the child.
If you're using table-per-class-hierarchy then you must have a discriminator field. You can use an Expression in a Criteria to test against the discriminator field.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 09, 2004 3:46 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Code:
from eg.Cat cat where cat.class = eg.DomesticCat


http://www.hibernate.org/hib_docs/refer ... yhql-where?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.