-->
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: Exclude Subclass from Criteria Query
PostPosted: Mon Feb 05, 2007 7:49 pm 
Newbie

Joined: Thu Jul 27, 2006 8:54 pm
Posts: 2
Using Hibernate 3 is it possible to create a criteria query that will exclude subclass from the results:

class Foo
class Bar extends Foo

Bar is mapped in hibernate as a subclass of Foo (joined-subclass in my case)

I would like to be able to write a criteria query that returns only objects whose class is Foo, not objects whose class is Bar.

Does anyone know if this is possible?

It's easy enough to write code to strip Bar instances from the results after the query has been run but this is ugly.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 11:04 pm 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
hi pei
try to filter it by discriminator field

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 12, 2007 6:32 am 
Newbie

Joined: Thu Apr 27, 2006 3:55 am
Posts: 4
You should do something like:
Code:
criteria.add(Restrictions.eq("class", Foo.class));

if it wasn't partially broken!

If you are using string discriminator types, a hibernate bug prevents a proper usage of this feature,
see http://opensource.atlassian.com/project ... se/HHH-746
for details on the "multiple double quotes issue".


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.