Wow, sounds a great thing to see in NH 3.2.


*Especially me personally investigating using stateless session in many
situations..*



*Mohamed Meligy
*Readify | Senior Developer

M:+61 451 835006 | W: readify.net
[image: Description: Description: Description: Description:
rss_16]<http://gurustop.net>
[image: Description: Description: Description: Description:
cid:[email protected]]
<http://www.linkedin.com/in/meligy>  [image:
Description: Description: Description: Description:
cid:[email protected]] <http://twitter.com/meligy>
 
<http://www.greatplacetowork.com.au/best/best-companies-australia.php><http://www.readify.net/AboutUs/NewsItem.aspx?id=10>



On Sat, Apr 23, 2011 at 11:36 AM, Rory Plaire <[email protected]> wrote:

> Apparenlty this is a limitation in the recursive load cycle of the
> stateless session whereby the temporary persistence context was being
> cleared on each recursive load, meaning previously loaded entities were not
> in the entity map.
>
> This issue was fixed in Hibernate, and I've ported the fix over to
> NHibernate here: http://216.121.112.228/browse/NH-2669
>
> -r
>
> On Thu, Apr 21, 2011 at 5:35 PM, Rory Plaire <[email protected]> wrote:
>
>> Hi all -
>>
>> I'm cross-posting this from SO, since although this is the "official"
>> channel, there is better findability over there.
>>
>>
>> http://stackoverflow.com/questions/5751197/eager-fetching-of-a-great-grandchild-collection-using-a-stateless-session-via-nhi
>>
>> I'm using an NHibernate Stateless Session to load bulk data into the
>> database. As data is loaded, later entities need to lookup previous entities
>> in order to add them to child collections. This operation involves needing
>> data on a grandchild object, which in turn needs a great-grandchild
>> collection to be available.
>>
>> The criteria looks like this:
>>
>> var result = InternalRepository.CreateCritera<Root>()
>>
>>
>>
>>                 .SetResultTransformer(Transformers.DistinctRootEntity)
>>
>>                 .Add(Restrictions.IdEq(id))
>>
>>                 .SetFetchMode("Child", FetchMode.Eager)
>>
>>                 .CreateAlias("Child", "a", JoinType.LeftOuterJoin)
>>
>>
>>
>>                 .SetFetchMode("a.Grandchild", FetchMode.Eager)
>>
>>                 .CreateAlias("Grandchild", "b", JoinType.LeftOuterJoin)
>>
>>
>>
>>                 .SetFetchMode("b.GreatGrandchildCollection", FetchMode.Eager)
>>
>>
>>
>>                 .UniqueResult<Root>();
>>
>> When I execute this, TwoPhaseLoad throws an exception during
>> InitializeEntity since the session's persistence context entity entries
>> are empty:
>>
>> at NHibernate.Engine.TwoPhaseLoad.InitializeEntity(Object entity, Boolean 
>> readOnly, ISessionImplementor session, PreLoadEvent preLoadEvent, 
>> PostLoadEvent postLoadEvent) in TwoPhaseLoad.cs: line 64
>>
>>
>>
>> at NHibernate.Loader.Loader.InitializeEntitiesAndCollections(IList 
>> hydratedObjects, Object resultSetId, ISessionImplementor session, Boolean 
>> readOnly) in Loader.cs: line 603
>>
>>
>>
>> at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, 
>> QueryParameters queryParameters, Boolean returnProxies) in Loader.cs: line 
>> 472
>>
>>
>>
>> at 
>> NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor
>>  session, QueryParameters queryParameters, Boolean returnProxies) in 
>> Loader.cs: line 243
>>
>>
>>
>> at NHibernate.Loader.Loader.DoList(ISessionImplementor session, 
>> QueryParameters queryParameters) in Loader.cs: line 1694
>>
>>
>> ...
>>
>> The entity the loader is looking up is the Child entity. Why is the
>> persistence context entries map empty here? The object is apparently being
>> fetched (the correct SQL is generated and returns correct results), and the
>> "Child" entity is created correctly. Why is the entity construction state
>> incorrect? Does it have to do with how the stateless session uses the
>> temporary persistence context during eager loads?
>>
>
>  --
> 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.
>

-- 
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.

Reply via email to