{"action":"created","issue":{"url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1719","repository_url":"https://api.github.com/repos/nhibernate/nhibernate-core","labels_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1719/labels{/name}","comments_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1719/comments","events_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1719/events","html_url":"https://github.com/nhibernate/nhibernate-core/issues/1719","id":328134526,"node_id":"MDU6SXNzdWUzMjgxMzQ1MjY=","number":1719,"title":"PropertyAccessException: Non-static method requires a target with one-to-one relations","user":{"login":"fubar-coder","id":4739844,"node_id":"MDQ6VXNlcjQ3Mzk4NDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4739844?v=4","gravatar_id":"","url":"https://api.github.com/users/fubar-coder","html_url":"https://github.com/fubar-coder","followers_url":"https://api.github.com/users/fubar-coder/followers","following_url":"https://api.github.com/users/fubar-coder/following{/other_user}","gists_url":"https://api.github.com/users/fubar-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/fubar-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fubar-coder/subscriptions","organizations_url":"https://api.github.com/users/fubar-coder/orgs","repos_url":"https://api.github.com/users/fubar-coder/repos","events_url":"https://api.github.com/users/fubar-coder/events{/privacy}","received_events_url":"https://api.github.com/users/fubar-coder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-05-31T13:17:05Z","updated_at":"2018-06-01T12:57:28Z","closed_at":null,"author_association":"NONE","body":"It seems that there is a problem with one-to-one relations or my mapping.\r\n\r\nException:\r\n\r\n```text\r\nException occurred getter of TestNhBug.FileEntry.Id\r\nNHibernate.PropertyAccessException: Exception occurred getter of TestNhBug.FileEntry.Id ---> System.Reflection.TargetException: Non-static method requires a target.\r\n   at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)\r\n   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)\r\n   at NHibernate.Properties.BasicPropertyAccessor.BasicGetter.Get(Object target)\r\n   --- End of inner exception stack trace ---\r\n   at NHibernate.Properties.BasicPropertyAccessor.BasicGetter.Get(Object target)\r\n   at NHibernate.Tuple.Entity.AbstractEntityTuplizer.GetIdentifier(Object entity)\r\n   at NHibernate.Persister.Entity.AbstractEntityPersister.IsTransient(Object entity, ISessionImplementor session)\r\n   at NHibernate.Engine.ForeignKeys.IsTransientFast(String entityName, Object entity, ISessionImplementor session)\r\n   at NHibernate.Engine.ForeignKeys.IsTransientSlow(String entityName, Object entity, ISessionImplementor session)\r\n   at NHibernate.Event.Default.DefaultDeleteEventListener.OnDelete(DeleteEvent event, ISet`1 transientEntities)\r\n   at NHibernate.Impl.SessionImpl.FireDelete(DeleteEvent event, ISet`1 transientEntities)\r\n   at NHibernate.Impl.SessionImpl.Delete(String entityName, Object child, Boolean isCascadeDeleteEnabled, ISet`1 transientEntities)\r\n   at NHibernate.Engine.Cascade.CascadeOn(IEntityPersister persister, Object parent, Object anything)\r\n   at NHibernate.Event.Default.AbstractFlushingEventListener.CascadeOnFlush(IEventSource session, IEntityPersister persister, Object key, Object anything)\r\n   at NHibernate.Event.Default.AbstractFlushingEventListener.PrepareEntityFlushes(IEventSource session)\r\n   at NHibernate.Event.Default.AbstractFlushingEventListener.FlushEverythingToExecutions(FlushEvent event)\r\n   at NHibernate.Event.Default.DefaultAutoFlushEventListener.OnAutoFlush(AutoFlushEvent event)\r\n   at NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet`1 querySpaces)\r\n   at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results, Object filterConnection)\r\n   at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results)\r\n   at NHibernate.Impl.AbstractSessionImpl.List(IQueryExpression queryExpression, QueryParameters parameters)\r\n   at NHibernate.Impl.AbstractQueryImpl2.List()\r\n   at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query, NhLinqExpression nhQuery)\r\n   at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)\r\n   at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)\r\n   at System.Linq.Queryable.Single[TSource](IQueryable`1 source, Expression`1 predicate)\r\n   at TestNhBug.Program.GetOrCreateEntry(ISession session, FileEntry parent, String name, Byte[] data) in c:\\users\\markjunker\\source\\repos\\TestNhBug\\TestNhBug\\Program.cs:line 99\r\n   at TestNhBug.Program.Main(String[] args) in c:\\users\\markjunker\\source\\repos\\TestNhBug\\TestNhBug\\Program.cs:line 36\r\n```\r\n\r\nThis are my mappings:\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<hibernate-mapping\r\n        assembly=\"TestNhBug\"\r\n        namespace=\"TestNhBug\"\r\n        xmlns=\"urn:nhibernate-mapping-2.2\">\r\n  <class name=\"FileEntry\" table=\"filesystementries\">\r\n    <id name=\"Id\" column=\"id\" generator=\"assigned\" />\r\n    <property name=\"ParentId\" column=\"parent_id\" />\r\n    <property name=\"Name\" column=\"name\" length=\"50\" not-null=\"true\" />\r\n    <one-to-one name=\"Data\" lazy=\"no-proxy\" cascade=\"all-delete-orphan\" />\r\n  </class>\r\n  <class name=\"FileData\" table=\"filesystementrydata\">\r\n    <id name=\"Id\" column=\"id\">\r\n      <generator class=\"foreign\">\r\n        <param name=\"property\">Entry</param>\r\n      </generator>\r\n    </id>\r\n    <property name=\"Data\" column=\"data\" not-null=\"true\" type=\"BinaryBlob\" lazy=\"true\" />\r\n    <one-to-one name=\"Entry\" lazy=\"no-proxy\" constrained=\"true\" foreign-key=\"fk_data_entry\" />\r\n  </class>\r\n</hibernate-mapping>\r\n```\r\n\r\nThis is my test application:\r\n\r\n```csharp\r\nusing System;\r\nusing System.Linq;\r\nusing System.Text;\r\n\r\nusing NHibernate;\r\n\r\nnamespace TestNhBug\r\n{\r\n    class Program\r\n    {\r\n        private static readonly Guid RootGuid = Guid.Parse(\"00000000-0000-0000-0000-000000000001\");\r\n\r\n        static void Main(string[] args)\r\n        {\r\n            var connectionString = @\"Data Source=(LocalDb)\\MSSQLLocalDB;Integrated Security=SSPI\";\r\n            var cfg = new NHibernate.Cfg.Configuration();\r\n            cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, \"NHibernate.Dialect.MsSql2012Dialect\");\r\n            cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionString, connectionString);\r\n            cfg.AddAssembly(typeof(FileData).Assembly);\r\n\r\n            var updater = new NHibernate.Tool.hbm2ddl.SchemaUpdate(cfg);\r\n            updater.Execute(true, true);\r\n\r\n            try\r\n            {\r\n                using (var sf = cfg.BuildSessionFactory())\r\n                {\r\n                    using (var session = sf.OpenSession())\r\n                    {\r\n                        using (var trans = session.BeginTransaction())\r\n                        {\r\n                            var rootEntry = GetOrCreateRootEntry(session);\r\n                            GetOrCreateEntry(session, rootEntry, \"text1.txt\",\r\n                                Encoding.UTF8.GetBytes(\"text1\"));\r\n                            var subEntry = GetOrCreateEntry(session, rootEntry, \"test1\");\r\n                            GetOrCreateEntry(session, subEntry, \"text1.txt\",\r\n                                Encoding.UTF8.GetBytes(\"text1 below test1\"));\r\n\r\n                            trans.Commit();\r\n                        }\r\n                    }\r\n                }\r\n\r\n                using (var sf = cfg.BuildSessionFactory())\r\n                {\r\n                    using (var session = sf.OpenSession())\r\n                    {\r\n                        using (var trans = session.BeginTransaction())\r\n                        {\r\n                            var entry = GetForPath(session, \"test1\", \"text1.txt\");\r\n\r\n                            session.Delete(entry);\r\n                            trans.Commit();\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                Console.Error.WriteLine(ex);\r\n            }\r\n        }\r\n\r\n        private static FileEntry GetForPath(ISession session, params string[] path)\r\n        {\r\n            var found = session.Load<FileEntry>(RootGuid);\r\n            foreach (var pathPart in path)\r\n            {\r\n                var next = session.Query<FileEntry>()\r\n                    .Single(x => x.ParentId == found.Id && x.Name == pathPart);\r\n                found = next;\r\n            }\r\n\r\n            return found;\r\n        }\r\n\r\n        private static FileEntry GetOrCreateRootEntry(ISession session)\r\n        {\r\n            var entry = session.Get<FileEntry>(RootGuid);\r\n\r\n            if (entry != null)\r\n                return entry;\r\n\r\n            entry = new FileEntry()\r\n            {\r\n                Id = RootGuid,\r\n                Name = string.Empty,\r\n            };\r\n\r\n            session.Save(entry);\r\n\r\n            session.Flush();\r\n\r\n            return entry;\r\n        }\r\n\r\n        private static FileEntry GetOrCreateEntry(ISession session, FileEntry parent, string name, byte[] data = null)\r\n        {\r\n            var entry = session.Query<FileEntry>()\r\n                .SingleOrDefault(x => x.Name == name && x.ParentId == parent.Id);\r\n            if (entry != null)\r\n                return entry;\r\n\r\n            entry = new FileEntry()\r\n            {\r\n                Id = Guid.NewGuid(),\r\n                ParentId = parent.Id,\r\n                Name = name,\r\n            };\r\n\r\n            FileData fileData;\r\n            if (data != null)\r\n            {\r\n                fileData = new FileData\r\n                {\r\n                    Entry = entry,\r\n                    Data = data,\r\n                };\r\n\r\n                entry.Data = fileData;\r\n            }\r\n            else\r\n            {\r\n                fileData = null;\r\n            }\r\n\r\n            session.Save(entry);\r\n\r\n            if (fileData != null)\r\n            {\r\n                session.Save(fileData);\r\n            }\r\n\r\n            session.Flush();\r\n\r\n            return entry;\r\n        }\r\n    }\r\n\r\n    public class FileData\r\n    {\r\n        public virtual Guid Id { get; set; }\r\n        public virtual byte[] Data { get; set; }\r\n        public virtual FileEntry Entry { get; set; }\r\n    }\r\n\r\n    public class FileEntry\r\n    {\r\n        public virtual Guid Id { get; set; }\r\n        public virtual Guid? ParentId { get; set; }\r\n        public virtual string Name { get; set; }\r\n        public virtual FileData Data { get; set; }\r\n    }\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/comments/393872304","html_url":"https://github.com/nhibernate/nhibernate-core/issues/1719#issuecomment-393872304","issue_url":"https://api.github.com/repos/nhibernate/nhibernate-core/issues/1719","id":393872304,"node_id":"MDEyOklzc3VlQ29tbWVudDM5Mzg3MjMwNA==","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-06-01T12:57:28Z","updated_at":"2018-06-01T12:57:28Z","author_association":"MEMBER","body":"This is either HHH-9663 or HHH-11965."}}
{"actor":{"display_login":"hazzik"}}