-
Notifications
You must be signed in to change notification settings - Fork 931
NH-3015 - Stateless Session with deduplicated result with join fetch #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@csharper2010 could you please provide any test case? |
Test Case added in 2012/5/18 Alexander Zaytsev <
|
Shows that the change made in StatelessSessionImpl.GetEntityUsingInterceptor effectively eliminates Duplicates in a Linq query with Join Fetch.
Signed-off-by: CSharper2010 <[email protected]>
I've added a test case now for FetchMany and ThenFetchMany. It's now based on current master. Message I got from "monkeypro": This change almost seems to solve my problem with stateless session! Execpt if I use FetchMany and ThenFetchMany I still get duplicate instances on the second level. |
I think this corresponds to Hibernate issue https://hibernate.atlassian.net/browse/HHH-2564 which also refers to the initial feature description for stateless sessions: https://hibernate.atlassian.net/browse/HHH-742, which contains this specification (shortened):
Issue HHH-2564 isn't fixed, since 2007. |
I'm not sure about HQL, but linq should follow linq semantic for sure. |
The weirdness (multiple root instances, but sharing the collection instance) I noted in NH-3705 I think indicates that the current behavior is a bug (or possibly unsupport/undefined behavior) (as opposed to this being a feature request). |
We already had https://nhibernate.jira.com/browse/NH-3015 apparently. |
NH-3015 is marked for 5.0. @hazzik This behavior sounds so buggy to me - do you think we really should hold it until 5.0 or should we do it in 4.1? |
Ok, let's do 4.1 But we need to make sure that all similar issues are fixed. |
@hazzik Did you have some specific case in mind, or do you just mean we should do more for different scenarios? |
@oskarb, no I don't have anything at the moment. |
Rebased and merged in a29dbf8. |
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...
... 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.