views:

206

answers:

0

Could any one explain why this query works beautifully when it is called by itself to load and fully hydrate a 3 level object graph in one fell swoop, but then fail when called immediately after an update and commit has been done on one of those children within the same session. To be clear, the SQL join is correctly created in both scenarios, but the child objects (the Many-To-One's) are not fully hydrated from the results after an update. I know the commit has been successful by the time this is called, because I can see the new data on a separate DB connection. In addition, it works perfectly if I close the session after the update, and call this in a brand new request/session.

EDIT: Forgot to mention this app uses the Open-Session-In-View pattern

public IList<Foo> FindFooByParentFooId(int parentId)
{
    ICriteria criteria = NHibernateSession.CreateCriteria(typeof(Foo));
    criteria.SetFetchMode("Many-To-One1", FetchMode.Join);
    criteria.SetFetchMode("Many-To-One2", FetchMode.Join);
    criteria.SetFetchMode("Many-To-One3", FetchMode.Join);

    ICriteria parentCriteria = criteria.CreateCriteria("ParentFoo");
    parentCriteria.Add(Expression.Eq("ParentFooId", parentId));

    return criteria.List<Foo>();
}