These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: correlated subquery support
PostPosted: Tue Jan 30, 2007 6:34 pm 
Beginner
Beginner

Joined: Wed Jul 05, 2006 12:45 pm
Posts: 21
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.