views:

828

answers:

4

I'm trying to build a HQL that can left join values from a collection, in order to give me the chance of checking "is null" on it.

Taken from the example from hibernate manual:

from Cat as cat
    left join cat.kittens as kitten
        with kitten.bodyWeight > 10.0

doesn't seem to work in NHibernate, since it doesn't recognize the "with" keyword. How else are you supposed to left join and check for no-matching entries if you cannot specify join-clauses directly in your join as opposed to in your WHERE-statement?

I'm running NHibernate 2.0.0.

+2  A: 

Unfortunately, this is not supported in NHibernate. It was first requested in 2005 and is by far the most popular requested feature.

Tim Scott
You don't happen to have any suggestion on a workaround, or if it can be achieved using a Criteria in some way?
jishi
I've voted for that suggestion as well, a while ago ... Hope that once upon a time, they implement it
Frederik Gheysels
A: 

I'm stuck with an HQL query requiring WITH keyword, is there any alternative for this ?

Cheers,

Depending on yor query, you can workaround it with left joins. I was stuck with the scenario where I needed to join with a specific clause and then check that it was null. I resorted to SQL instead for the time beeing.
jishi
+1  A: 

I think you can workaround it by using an outer join, and then do this:

from Cat c
left join c.Kittens as kitten
where kitten.bodyweight > 10 or kitten.bodyweight is null
Frederik Gheysels
+1  A: 

Apparently they're working on it ... http://nhjira.koah.net/browse/NH-514

I've received an update report from the NHibernate JIRA yesterday, and this issue should be fixed in NHibernate v2.1.0 Alpha 3 :)

Frederik Gheysels