-->
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: HQL instanceof
PostPosted: Tue Sep 28, 2004 8:00 am 
Newbie

Joined: Tue Jul 20, 2004 7:03 am
Posts: 19
Location: Spain
Hi all:

Is there any method to reproduce the 'instanceof' operator in a hql query ?

My case:
Code:
class Container has reference to class Parent

class Son1 extends class Parent
class Son2 extends class Parent


My query is:
"Get all the containers whith a reference to a Son1 class"

Thanks !


Hibernate version:2.1.6


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 28, 2004 8:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
where foo.class = pkg.Bar


not exactly an instanceof, but close


Top
 Profile  
 
 Post subject: Re: HQL instanceof
PostPosted: Thu Aug 18, 2005 9:32 am 
Newbie

Joined: Tue Jul 12, 2005 5:41 am
Posts: 7
I guess you would like something similar to:

Code:
select c from Container c inner join c.contents cc where cc instanceof Son1


I think you can emulate it with a correct behaviour by translating the "instanceof" with a subquery:

Code:
select c from Container c inner join c.contents cc where exists (from Son1 cc1 where cc1 = cc)


Am I right?


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.