I'd like to let NHibernate generate a query which has 'additional'
join conditions.
More specificly, I have this HQL query:
[code]
IQuery q = session.CreateQuery ("select new PrestationView(p.Id,
p.Code, pn.Name) " +
            " from Prestation as p left outer join p.Names as pn " +
            "where pn.Language = 1");
[/code]

NHibernate generates an SQL Statement which looks like:
[code]
SELECT p.Id, p.Code, pn.Name
FROM Prestation
LEFT JOIN PrestationName ON PrestationName.PrestationId =
Prestation.Id
WHERE PrestationName.Language = 1
[/code]

However, this does not return the results that I want.  I want that
the Prestations that have no Name with languagecode = 1 are returned
as well.
Using SQL, I can easily solve this by putting the condition that is in
the WHERE clause, in the JOIN clause.
So, in fact, I'd like that NHibernate generates this query for me:
[code]
SELECT ...
FROM Prestation
LEFT JOIN PrestationName ON PrestationName.PrestationId =
Prestatoin.Id AND LanguageCode = 1
[/code]

In the reference documentation of Hibernate (not NHibernate :) ), I
see that HQL in Hibernate has an additional keyword 'with', which can
be used to specify such join-conditions:
[url="http://www.hibernate.org/hib_docs/reference/en/html/queryhql-
joins.html"]klik[/url]:

[quote]
You may supply extra join conditions using the HQL with keyword.

from Cat as cat
    left join cat.kittens as kitten
        with kitten.bodyWeight > 10.0
[/quote]

However, it seems that NHibernate does not support this 'with'
keyword ?

Is there any other way to specify such extra join conditions in
NHibernate HQL or using Criteria ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to