{"action":"created","issue":{"url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1570","repository_url":"https://api.github.com/repos/nhibernate/nhibernate-core","labels_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1570/labels{/name}","comments_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1570/comments","events_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1570/events","html_url":"https://github.com/nhibernate/nhibernate-core/issues/1570","id":295121556,"number":1570,"title":"Results are multiple with the same id","user":{"login":"csharpdeveloper12","id":25053369,"avatar_url":"https://avatars0.githubusercontent.com/u/25053369?v=4","gravatar_id":"","url":"https://api.github.com/users/csharpdeveloper12","html_url":"https://github.com/csharpdeveloper12","followers_url":"https://api.github.com/users/csharpdeveloper12/followers","following_url":"https://api.github.com/users/csharpdeveloper12/following{/other_user}","gists_url":"https://api.github.com/users/csharpdeveloper12/gists{/gist_id}","starred_url":"https://api.github.com/users/csharpdeveloper12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csharpdeveloper12/subscriptions","organizations_url":"https://api.github.com/users/csharpdeveloper12/orgs","repos_url":"https://api.github.com/users/csharpdeveloper12/repos","events_url":"https://api.github.com/users/csharpdeveloper12/events{/privacy}","received_events_url":"https://api.github.com/users/csharpdeveloper12/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-07T12:35:31Z","updated_at":"2018-02-21T04:35:50Z","closed_at":null,"author_association":"NONE","body":"Hi :),\r\n\r\ni have a strange behavior with `ISet<>` and `FetchMode`.\r\n\r\nEntity:\r\n```\r\npublic class T1\r\n{\r\npublic virtual System.Guid Id {get; set; }\r\npublic virtual System.Collections.Generic.ISet<T2> Items { get; set; }\r\n}\r\n```\r\n\r\nMapping1:\r\n```\r\npublic class T1\r\n{\r\n...\r\nbase.Set(x => x.Items,\r\ny =>\r\n{\r\ny.Cascade(NHibernate.Mapping.ByCode.Cascade.All);\r\ny.Fetch(NHibernate.Mapping.ByCode.CollectionFetchMode.Join);\r\ny.Lazy(NHibernate.Mapping.ByCode.CollectionLazy.NoLazy);\r\n},\r\nz => { ... }\r\n);\r\n}\r\n```\r\n\r\nMapping2:\r\n```\r\npublic class T1\r\n{\r\n...\r\nbase.Set(x => x.Items,\r\ny =>\r\n{\r\ny.Cascade(NHibernate.Mapping.ByCode.Cascade.All);\r\ny.Fetch(NHibernate.Mapping.ByCode.CollectionFetchMode.Subselect);\r\ny.Lazy(NHibernate.Mapping.ByCode.CollectionLazy.NoLazy);\r\n},\r\nz => { ... }\r\n);\r\n}\r\n```\r\n\r\nNow i persist 1 T1 with 3 T2 items.\r\n\r\n`var items = session.QueryOve<T1>().List();`\r\n- If i execute `QueryOver<T1>` with Mapping2 everthing is ok.\r\nitems hast 1 item with 3 nested items (T2)\r\n- But if i execute `QueryOver<T1>` with Mapping1 the behavior is:\r\nitems has 3 items (with the same id) and each item has 3 nested items (T2)\r\n\r\nIs this an bug or correct if i use FetchMode.Join and the failure is by me and i forgot something in the mapping?"},"comment":{"url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/comments/367210973","html_url":"https://github.com/nhibernate/nhibernate-core/issues/1570#issuecomment-367210973","issue_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1570","id":367210973,"user":{"login":"bahusoid","id":22025304,"avatar_url":"https://avatars1.githubusercontent.com/u/22025304?v=4","gravatar_id":"","url":"https://api.github.com/users/bahusoid","html_url":"https://github.com/bahusoid","followers_url":"https://api.github.com/users/bahusoid/followers","following_url":"https://api.github.com/users/bahusoid/following{/other_user}","gists_url":"https://api.github.com/users/bahusoid/gists{/gist_id}","starred_url":"https://api.github.com/users/bahusoid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bahusoid/subscriptions","organizations_url":"https://api.github.com/users/bahusoid/orgs","repos_url":"https://api.github.com/users/bahusoid/repos","events_url":"https://api.github.com/users/bahusoid/events{/privacy}","received_events_url":"https://api.github.com/users/bahusoid/received_events","type":"User","site_admin":false},"created_at":"2018-02-21T04:35:50Z","updated_at":"2018-02-21T04:35:50Z","author_association":"CONTRIBUTOR","body":"Looks like expected behavior. You can see the same behavior if you join/fetch lazy collection directly in query.\r\n\r\nAnd unfortunately you can't fix it in the mapping - if you need to have FetchMode.Join for collection in mapping you need to remember to add distinct transformer to all your queries \r\n`session.QueryOver<T1>().Using(Transformers.DistinctRootEntity).List();` \r\n\r\n\r\n"}}
{"actor":{"display_login":"bahusoid"}}