Skip to content

Conversation

csharper2010
Copy link
Contributor

See thread on Google Group
http://groups.google.com/group/nhibernate-development/browse_thread/thread/39596596dcb44679

I found that when eager fetching entities like this...
using (var session =
sessionFactory.OpenStatelessSession())
using (var transaction = session.BeginTransaction())
{
var list = session.Query()
.FetchMany(a => a.OrderLines)
.ThenFetch(p => p.Product).ToList();
Assert.AreEqual(2, list.Count(a => a.OrderLines
.Any(p => p.Product.Name.Contains("soft"))));
}

... I get too many aggregate roots in the result, there are duplicate
instances for the same entity. For the stateless session it might be
even more important that the join fetch works as expected because lazy
loading is disabled for it.

With a small modification that would be fixed without the need to use
some result transformers. The stateless session uses a temporary
stateful persistence context and while a Query we could use its
already loaded entities to maintain the object identity thus
deduplicating the result. After the query is finished, the persistence
context is cleared so there is side effect for later queries. I've run
the NHibernate.Test unit tests and they work fine except for those
that have been red on my machine before the change.

select xxx from yyy order by zzz offset @p1 rows fetch first @p2 rows only
@csharper2010
Copy link
Contributor Author

Now there's NH-3015 for that on Jira.

@hazzik
Copy link
Member

hazzik commented May 18, 2012

It seems that pull request is broken: there is commits about paging for Ms Sql 2012 and not about the subject of the pull request. So, I close it.

@csharper2010 when you will create a pull request in the next time, please use a feature branch and not master.

@hazzik hazzik closed this May 18, 2012
@csharper2010
Copy link
Contributor Author

Hi,

I've created a new pull request now --> #111.

This was my first touch with git so I did not know how to handle this. Now
I found how I can create feature branches on my github fork.

CSharper

2012/5/18 Alexander Zaytsev <
[email protected]

It seems that pull request is broken: there is commits about paging for Ms
Sql 2012 and not about the subject of the pull request. So, I close it.

@csharper2010 when you will create a pull request in the next time, please
use a feature branch and not master.


Reply to this email directly or view it on GitHub:
#50 (comment)

@monkeypro
Copy link

This change seems to solve my problem with stateless session!
Since I'm completely new to GitHub (5 minutes), I know nothing about how things work with commits and new releases. When can I get a stable version of NHibernate with this fix in it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants