{"action":"created","issue":{"url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1920","repository_url":"https://api.github.com/repos/nhibernate/nhibernate-core","labels_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1920/labels{/name}","comments_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1920/comments","events_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1920/events","html_url":"https://github.com/nhibernate/nhibernate-core/issues/1920","id":387762279,"node_id":"MDU6SXNzdWUzODc3NjIyNzk=","number":1920,"title":"ISession.Get may fail with a null exception","user":{"login":"RogerKratz","id":1101237,"node_id":"MDQ6VXNlcjExMDEyMzc=","avatar_url":"https://avatars0.githubusercontent.com/u/1101237?v=4","gravatar_id":"","url":"https://api.github.com/users/RogerKratz","html_url":"https://github.com/RogerKratz","followers_url":"https://api.github.com/users/RogerKratz/followers","following_url":"https://api.github.com/users/RogerKratz/following{/other_user}","gists_url":"https://api.github.com/users/RogerKratz/gists{/gist_id}","starred_url":"https://api.github.com/users/RogerKratz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RogerKratz/subscriptions","organizations_url":"https://api.github.com/users/RogerKratz/orgs","repos_url":"https://api.github.com/users/RogerKratz/repos","events_url":"https://api.github.com/users/RogerKratz/events{/privacy}","received_events_url":"https://api.github.com/users/RogerKratz/received_events","type":"User","site_admin":false},"labels":[{"id":718470693,"node_id":"MDU6TGFiZWw3MTg0NzA2OTM=","url":"https://api.github.com/repos/nhibernate/nhibernate-core/labels/Regression","name":"Regression","color":"b60205","default":false},{"id":717851256,"node_id":"MDU6TGFiZWw3MTc4NTEyNTY=","url":"https://api.github.com/repos/nhibernate/nhibernate-core/labels/c:%20Core","name":"c: Core","color":"ededed","default":false},{"id":717887556,"node_id":"MDU6TGFiZWw3MTc4ODc1NTY=","url":"https://api.github.com/repos/nhibernate/nhibernate-core/labels/p:%20Major","name":"p: Major","color":"d93f0b","default":false},{"id":661449753,"node_id":"MDU6TGFiZWw2NjE0NDk3NTM=","url":"https://api.github.com/repos/nhibernate/nhibernate-core/labels/t:%20Bug","name":"t: Bug","color":"d93f0b","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/nhibernate/nhibernate-core/milestones/22","html_url":"https://github.com/nhibernate/nhibernate-core/milestone/22","labels_url":"https://api.github.com/repos/nhibernate/nhibernate-core/milestones/22/labels","id":3876345,"node_id":"MDk6TWlsZXN0b25lMzg3NjM0NQ==","number":22,"title":"5.2.1","description":"","creator":{"login":"fredericDelaporte","id":12201973,"node_id":"MDQ6VXNlcjEyMjAxOTcz","avatar_url":"https://avatars2.githubusercontent.com/u/12201973?v=4","gravatar_id":"","url":"https://api.github.com/users/fredericDelaporte","html_url":"https://github.com/fredericDelaporte","followers_url":"https://api.github.com/users/fredericDelaporte/followers","following_url":"https://api.github.com/users/fredericDelaporte/following{/other_user}","gists_url":"https://api.github.com/users/fredericDelaporte/gists{/gist_id}","starred_url":"https://api.github.com/users/fredericDelaporte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredericDelaporte/subscriptions","organizations_url":"https://api.github.com/users/fredericDelaporte/orgs","repos_url":"https://api.github.com/users/fredericDelaporte/repos","events_url":"https://api.github.com/users/fredericDelaporte/events{/privacy}","received_events_url":"https://api.github.com/users/fredericDelaporte/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":0,"state":"open","created_at":"2018-12-06T10:26:09Z","updated_at":"2018-12-06T16:50:40Z","due_on":"2019-01-02T08:00:00Z","closed_at":null},"comments":12,"created_at":"2018-12-05T13:42:16Z","updated_at":"2018-12-06T19:36:21Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"`ISession.Get` fails with an \"`InvalidOperationException` : Nullable object must have a value\" when the entity class has batch lazy-loads enabled and at least one but less than `batch-size` other instances of the entity class are proxies awaiting loading.\r\n(The get has to be done on an entity not yet loaded, even as an uninitialized proxy.)\r\n\r\nInitial report:\r\n---\r\n\r\n\r\nRegression bug for 5.2.\r\n\r\nWe have a bunch of tests that after upgrade to 5.2 fails with stack trace below. Tried to figure out what/when this occur but no success yet. I guess there are some particular mapping that causes this? \r\nIt happens both in tests when Get as well as Merge is called. \r\n\r\nThe commit when this was added was 09120c02b3816f92d154e4c5b0e47daa0171eb16. \r\n\r\nI've tried to isolate this problem to a small test but haven't really found out what causes this. ping @maca88 - do you have a guess when this could happen?\r\n\r\n\r\n```\r\nSystem.InvalidOperationException : Nullable object must have a value.\r\n   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)\r\n   at NHibernate.Engine.BatchFetchQueue.<GetEntityBatch>g__CheckCacheAndProcessResult|25_0(<>c__DisplayClass25_0& )\r\n   at NHibernate.Engine.BatchFetchQueue.GetEntityBatch(IEntityPersister persister, Object id, Int32 batchSize, Boolean checkCache)\r\n   at NHibernate.Loader.Entity.BatchingEntityLoader.Load(Object id, Object optionalObject, ISessionImplementor session)\r\n   at NHibernate.Persister.Entity.AbstractEntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session)\r\n   at NHibernate.Event.Default.DefaultLoadEventListener.LoadFromDatasource(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options)\r\n   at NHibernate.Event.Default.DefaultLoadEventListener.DoLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options)\r\n   at NHibernate.Event.Default.DefaultLoadEventListener.Load(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options)\r\n   at NHibernate.Event.Default.DefaultLoadEventListener.ProxyOrLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options)\r\n   at NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType)\r\n   at NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType)\r\n   at NHibernate.Impl.SessionImpl.InternalLoad(String entityName, Object id, Boolean eager, Boolean isNullable)\r\n   at NHibernate.Type.EntityType.ResolveIdentifier(Object id, ISessionImplementor session)\r\n   at NHibernate.Type.EntityType.Replace(Object original, Object target, ISessionImplementor session, Object owner, IDictionary copyCache)\r\n   at NHibernate.Type.CollectionType.ReplaceElements(Object original, Object target, Object owner, IDictionary copyCache, ISessionImplementor session)\r\n   at NHibernate.Type.CollectionType.Replace(Object original, Object target, ISessionImplementor session, Object owner, IDictionary copyCache)\r\n   at NHibernate.Type.TypeHelper.Replace(Object[] original, Object[] target, IType[] types, ISessionImplementor session, Object owner, IDictionary copiedAlready)\r\n   at NHibernate.Event.Default.DefaultMergeEventListener.CopyValues(IEntityPersister persister, Object entity, Object target, ISessionImplementor source, IDictionary copyCache)\r\n   at NHibernate.Event.Default.DefaultMergeEventListener.EntityIsDetached(MergeEvent event, IDictionary copyCache)\r\n   at NHibernate.Event.Default.DefaultMergeEventListener.OnMerge(MergeEvent event, IDictionary copiedAlready)\r\n   at NHibernate.Impl.SessionImpl.FireMerge(IDictionary copiedAlready, MergeEvent event)\r\n   at NHibernate.Impl.SessionImpl.Merge(String entityName, Object obj, IDictionary copiedAlready)\r\n   at NHibernate.Engine.CascadingAction.MergeCascadingAction.Cascade(IEventSource session, Object child, String entityName, Object anything, Boolean isCascadeDeleteEnabled)\r\n   at NHibernate.Engine.Cascade.CascadeToOne(Object parent, Object child, IType type, CascadeStyle style, Object anything, Boolean isCascadeDeleteEnabled)\r\n   at NHibernate.Engine.Cascade.CascadeCollectionElements(Object parent, Object child, CollectionType collectionType, CascadeStyle style, IType elemType, Object anything, Boolean isCascadeDeleteEnabled)\r\n   at NHibernate.Engine.Cascade.CascadeCollection(Object parent, Object child, CascadeStyle style, Object anything, CollectionType type)\r\n   at NHibernate.Engine.Cascade.CascadeAssociation(Object parent, Object child, IType type, CascadeStyle style, Object anything, Boolean isCascadeDeleteEnabled)\r\n   at NHibernate.Engine.Cascade.CascadeOn(IEntityPersister persister, Object parent, Object anything)\r\n   at NHibernate.Event.Default.DefaultMergeEventListener.CascadeOnMerge(IEventSource source, IEntityPersister persister, Object entity, IDictionary copyCache)\r\n   at NHibernate.Event.Default.DefaultMergeEventListener.EntityIsDetached(MergeEvent event, IDictionary copyCache)\r\n   at NHibernate.Event.Default.DefaultMergeEventListener.OnMerge(MergeEvent event, IDictionary copiedAlready)\r\n   at NHibernate.Impl.SessionImpl.FireMerge(IDictionary copiedAlready, MergeEvent event)\r\n   at NHibernate.Impl.SessionImpl.Merge(String entityName, Object obj, IDictionary copiedAlready)\r\n   at NHibernate.Engine.CascadingAction.MergeCascadingAction.Cascade(IEventSource session, Object child, String entityName, Object anything, Boolean isCascadeDeleteEnabled)\r\n   at NHibernate.Engine.Cascade.CascadeToOne(Object parent, Object child, IType type, CascadeStyle style, Object anything, Boolean isCascadeDeleteEnabled)\r\n   at NHibernate.Engine.Cascade.CascadeCollectionElements(Object parent, Object child, CollectionType collectionType, CascadeStyle style, IType elemType, Object anything, Boolean isCascadeDeleteEnabled)\r\n   at NHibernate.Engine.Cascade.CascadeCollection(Object parent, Object child, CascadeStyle style, Object anything, CollectionType type)\r\n   at NHibernate.Engine.Cascade.CascadeAssociation(Object parent, Object child, IType type, CascadeStyle style, Object anything, Boolean isCascadeDeleteEnabled)\r\n   at NHibernate.Engine.Cascade.CascadeOn(IEntityPersister persister, Object parent, Object anything)\r\n   at NHibernate.Event.Default.DefaultMergeEventListener.CascadeOnMerge(IEventSource source, IEntityPersister persister, Object entity, IDictionary copyCache)\r\n   at NHibernate.Event.Default.DefaultMergeEventListener.EntityIsDetached(MergeEvent event, IDictionary copyCache)\r\n   at NHibernate.Event.Default.DefaultMergeEventListener.OnMerge(MergeEvent event, IDictionary copiedAlready)\r\n   at NHibernate.Event.Default.DefaultMergeEventListener.OnMerge(MergeEvent event)\r\n   at NHibernate.Impl.SessionImpl.FireMerge(MergeEvent event)\r\n   at NHibernate.Impl.SessionImpl.Merge(String entityName, Object obj)\r\n   at NHibernate.Impl.SessionImpl.Merge[T](T entity)\r\n```"},"comment":{"url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/comments/445001678","html_url":"https://github.com/nhibernate/nhibernate-core/issues/1920#issuecomment-445001678","issue_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1920","id":445001678,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NTAwMTY3OA==","user":{"login":"hazzik","id":144791,"node_id":"MDQ6VXNlcjE0NDc5MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/144791?v=4","gravatar_id":"","url":"https://api.github.com/users/hazzik","html_url":"https://github.com/hazzik","followers_url":"https://api.github.com/users/hazzik/followers","following_url":"https://api.github.com/users/hazzik/following{/other_user}","gists_url":"https://api.github.com/users/hazzik/gists{/gist_id}","starred_url":"https://api.github.com/users/hazzik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hazzik/subscriptions","organizations_url":"https://api.github.com/users/hazzik/orgs","repos_url":"https://api.github.com/users/hazzik/repos","events_url":"https://api.github.com/users/hazzik/events{/privacy}","received_events_url":"https://api.github.com/users/hazzik/received_events","type":"User","site_admin":false},"created_at":"2018-12-06T19:36:21Z","updated_at":"2018-12-06T19:36:21Z","author_association":"MEMBER","body":"I agree with @RogerKratz "}}
{"actor":{"display_login":"hazzik"}}