0

Using NHibernate for .NET I have 3 tables. One is CourseType, the other is Contact and the last being a composite called CourseType_Contact the composite table looks like this...

CourseTypeID Guid, ContactID Guid

I am attempting to use HQL to write a query that will retrieve all the Contacts for a specific coursetype but I'm lost as to how to do this in HQL.

In SQL my query would look like this.

SELECT * FROM Contact WHERE ContactID IN(
SELECT ContactID FROM CourseType_Contact WHERE CourseTypeID = @CourseTypeID)

Could anyone point me in the right direction?

Maxim Gershkovich
  • 45,951
  • 44
  • 147
  • 243

1 Answers1

0

Long time not using HQL, but I think you could do

SELECT co FROM CourseType ct 
JOIN   ct.Contacts co
WHERE  ct.CourseTypeId = :Id
Claudio Redi
  • 67,454
  • 15
  • 130
  • 155