Can anyone comment on the support in beta3 for "correlated subqueries" - using aliases from the outer query in the subquery?
From the JIRA issue, it seems that the port from H3 is complete:
http://jira.nhibernate.org/browse/NH-783
I am able to use it perfectly using HQL:
Code:
from Entity outer"
where outer.Number >
(select count(inner.ID)
from Entity2 inner
where inner.Property = outer.Property)
However, if i try to build the same query using the Criteria API (by specifying an alias for both the outer criteria and the inner detached subcriteria), I get an error. This is my sample code:
Code:
DetachedCriteria innerCriteria = DetachedCriteria.For(typeof(Entity2), "inner");
innerCriteria.Add(Expression.EqProperty("inner.Property", "outer.Property"));
innerCriteria.SetProjection(Projections.Count("inner.ID"));
ICriteria outerCriteria = session.CreateCriteria(typeof(Entity), "outer");
outerCriteria.Add(Subqueries.PropertyGt("Property", innerCriteria));
Running the outer criteria generates an error stating that "outer" is not a property of the Entity2 (inner) class, so it doesn't seem to interpret "outer" as an alias of the outer criteria.
Can anyone comment on whether this "correlated subquery" is supported through the Criteria API?
Thanks very much in advance.
Hibernate version:
1.2.0 beta3