views:

1356

answers:

3

In my domain model I have an abstract class CommunicationChannelSpecification, which has child classes like FTPChannelSpecification, EMailChannelSpecification and WebserviceChannelSpecification. Now I want to create an HQL query which contains a where clause that narrows down the result to certain types of channel specifications. E.g. (in plain English) select all CommunicationChannelSpecifications that whose types occur in the set {FTPChannelSpecification, WebserviceChannelSpecification}.

How can this be achieved in HQL? I'm using NHibernate 2.0.1 and a table per subclass inheritance mapping strategy...

Thanks!

Pascal

+3  A: 

Not positive in NHibernate, but in Hibernate, there are two special properties that are always referenced id and class. So, for your particular case, I'd do

from CommunicationChannelSpecifications spec where spec.class in (?)
bangroot
A: 

NHibernate supports the same syntax as Hibernate in this case. See here for an example.

Sean Carpenter
A: 

Thanks a million guys! I have completely looked over that in the documentation!

Pascal Lindelauf