fetch="join" works, but FetchMode.Eager doesn't?

80 views
Skip to first unread message

Luke Bakken

unread,
Apr 6, 2009, 12:12:25 PM4/6/09
to nhu...@googlegroups.com
Hi everyone,

I'm sure I'm just doing something a little wrong, but I wanted to
eager-load the objects represented by these lines in my hbm:

<many-to-one name="CreatedBy" class="User" column="CreatedByUserUID"
access="field.camelcase-underscore" cascade="none" not-null="true"
foreign-key="FK_Users_WorkflowItems_CreatedBy" fetch="join" />

<many-to-one name="OwnedBy" class="User" column="OwnedByUserUID"
access="field.camelcase-underscore" cascade="none" not-null="true"
foreign-key="FK_Users_WorkflowItems_OwnedBy" fetch="join" />

At first I tried using "FetchMode.Eager" in my DAO for retrieving the
class (WorkflowItem) that contains the above associations:

ICriteria crit = NHibernateSession.CreateCriteria(typeof(WorkflowItem), "wf");
crit.SetFetchMode("wf.CreatedBy", FetchMode.Eager);
crit.SetFetchMode("wf.OwnedBy", FetchMode.Eager);

But the above code did not produce the expected joins in the output
SQL. Adding 'fetch="join"' in the hbm works like a charm.

Any ideas?
Thanks,
Luke

Reply all
Reply to author
Forward
0 new messages