2010-03-28 3 views
0

매핑을 건드리지 않고 HQL로 열심히로드 할 수 있습니까? nHibernate는 "left join fetch"표현식을 완전히 무시한다.HQL로 열심히로드하기

var query = Session.CreateQuery("from o in Member left join fetch o.Photos"); 
query.List<Member>(); 

생성 된 SQL은 사진을 잡는

SELECT this_.Id as Id7_1_, this_.Name as Name7_1_, this_.AltNames as AltNames7_1_, 
this_.Tags as Tags7_1_, this_.Loved as Loved7_1_, profile2_.id as id6_0_, 
profile2_.Website as Website6_0_, profile2_.Email as Email6_0_, 
profile2_.Shop as Shop6_0_ 
FROM Member this_ 
left outer join member_profile profile2_ on this_.Id=profile2_.id 
limit 10; 

그리고 10 문이다. MemberProfile은 OneToOne로 매핑됩니다. 이 간절히 Mate 관계를로드

from Cat as cat inner join fetch cat.Mate 

:

답변

4

당신은 fetch 키워드를 사용할 수 있습니다.

+0

"join fetch"부분을 완전히 무시합니다. –

+0

더 많은 컨텍스트를 제공하고 코드를 표시 할 수 있습니까? –

+0

왼쪽 가입은 어떻습니까? 'cat from cat from cat. 고양이에 빠지다 .Kittens'? –

관련 문제