-->
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.  [ 2 posts ] 
Author Message
 Post subject: Selecting subclasses in class hierarchy
PostPosted: Thu Jun 08, 2006 2:24 pm 
Newbie

Joined: Thu Jun 08, 2006 2:16 pm
Posts: 2
Hey everybody,

I have a class hierarchy (table per hierarchy) and would like to return only certain subclasses from this hierarchy that satisfy certain criteria.

Class hierarchy looks like this:
A -|
|-B
|-C
|-D
|-E

Let's assume that the superclass has a property called foo.

I need to return all subclasses of type B and C (but not D and E) where property foo has a value of 'bar'.

Is it possible to do?

Thanks,
-Dmitri


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 08, 2006 9:06 pm 
Newbie

Joined: Thu Jun 08, 2006 2:16 pm
Posts: 2
Looks like it is possible to do with an HQL query. Let's assume that discriminator column name is DISCRIMINATOR and its values are 'B', 'C', 'D' and 'E'. Then to select subclasses B and C with property foo set to bar:

from A where foo = bar and (DISCRIMINATOR='B' or DISCRIMINATOR='C')

Also, could someone explain why it is possible to use discriminator column in HQL queries, but impossible in criteria queries?

Cheers,
-Dmitri


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