【发布时间】:2010-03-28 19:58:47
【问题描述】:
是否可以在不触及映射的情况下使用 HQL 进行预加载? nHibernate 完全忽略了“left join fetch”表达式。
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。
【问题讨论】:
标签: c# nhibernate