-->
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: Polymorphic query
PostPosted: Thu Nov 17, 2005 11:12 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Is it possible to create a polymorphic query where you are selecting a base class but specifying criteria on one or more derived classes?

For example, I have a base class Profile which has derived classes FtpProfile and SmtpProfile which provide additional properties. What I want to do is be able to cast the base class referred to in the FROM clause to one of the subclasses in the WHERE clause.

eg: (pseudo hql/wish)
Code:
SELECT p FROM Profile p WHERE ((FtpProfile)p.)RootFolder = '\admin' OR ((SmtpProfile)p).Address = 'admin@somewhere.com'


Is there any way to do something like this?

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 12:25 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
It would be possible if there was UNION in HQL, but currently, you have to run a separated query for each subclass.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 6:07 pm 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Doh... :cry:


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.