Hmm, how does the relevant parts of your classes and mappings look?
Also, that SQL is using a correlated subquery and may perform badly.
You might want to compare performance with this alternative SQL:
select * from Question q where q.id in
(select rq.ParentId from RelatedQuestion rq
group by rq.parentId
having count(*) > 1)
/Oskar
2010/5/22 Cosmo <[email protected]>:
> Hello Guys!
>
> This SQL works for me:
>
> select * from Question q where (select COUNT(*) from RelatedQuestion
> rq where q.Id = rq.ParentId) > 1
>
> Now I try to convert it to Criteria API:
>
> DetachedCriteria subCriteria = DetachedCriteria.For<Question>("rq")
>
> .CreateCriteria("RelatedQuestions").SetProjection(Projections.RowCount())
> .Add(Restrictions.EqProperty("rq.ParentId", "q.Id"));
>
> DetachedCriteria criteria =
> DetachedCriteria.For<Question>("q").Add(Subqueries.Le(1,
> subCriteria));
> IList<Question> results = Question.FindAll(criteria);
>
> As a result I get: "Could not find a matching criteria info provider
> to: NHibernate.Impl.CriteriaImpl+Subcriteria".
>
> Any ideas to help me out?
>
> Regards,
> Jakub
>
> --
> 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.
>
>
--
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.