so I got a query like this:
query =
Session.CreateQuery(@"select
(select ch from e.Course.Chapters ch where ch.Number =
:requestedChapterNumber) as RequestedChapter
>From Enrollment e
where e.User.UserName =:userName
and e.Name = :name");
query.SetParameter("userName", userName)
.SetParameter("name", enrollmentName)
.SetParameter("requestedChapterNumber", requestedChapterNumber);
query.SetResultTransformer(Transformers.AliasToBean<CourseLoader>()).UniqueResult<CourseLoader>();
This generate the following *two *SQL
select (select chapters2_.Id
from Courses course1_,
Chapters chapters2_
where enrollment0_.CourseFk = course1_.Id
and course1_.Id = chapters2_.CourseFk
and chapters2_.Number = 1 /* @p2 */) as col_0_0_
from Enrollments enrollment0_,
Users user3_
where enrollment0_.UserFk = user3_.Id
and user3_.UserName = 'Hoang' /* @p0 */
and enrollment0_.Name = 'Test' /* @p1 */
SELECT chapter0_.Id as Id11_0_,
chapter0_.Title as Title11_0_,
chapter0_.Overview as Overview11_0_,
chapter0_.Number as Number11_0_,
FROM Chapters chapter0_
WHERE chapter0_.Id = 'e50e77f5-2dc9-43ac-b6b3-9e1f00ed6fd3' /* @p0 */
Is there anyway I can tell NH to load the whole RequestedChapter right off
the first subselect so it doesn't have to generate a second select? The
whole reason I use the SetResultTransformer is so I can get everything in
one select, there are more properties to load... but I narrowed it down to
this.
Is this a bug?
--
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.