{"id":521,"date":"2018-05-25T11:57:15","date_gmt":"2018-05-25T11:57:15","guid":{"rendered":"http:\/\/bruceng.com\/dev\/?p=521"},"modified":"2021-02-01T08:29:42","modified_gmt":"2021-02-01T08:29:42","slug":"nhibernate-unable-to-resolve-property-_property","status":"publish","type":"post","link":"https:\/\/bruceng.com\/dev\/?p=521","title":{"rendered":"NHibernate: Unable to resolve property: _Property"},"content":{"rendered":"<p>This issue occurred when<\/p>\n<ul>\n<li>There are two entities, same class, same table, different entity names.<\/li>\n<li>Both entities have one-to-many relationship to a child table<\/li>\n<li>Both one-to-many relationships specify the foreign key column as not-null=&#8221;true&#8221;<\/li>\n<li>Try to call Session.Merge on one entity, with additional new child entities inside.<\/li>\n<\/ul>\n<p>After trying random configurations, somehow removing not-null=&#8221;true&#8221; from one entity hbm mapping solves this issue.<\/p>\n<p>No idea why, the only way is, perhaps, to debug NHibernate code.<\/p>\n<p>Update in Jan 2021: Seems that setting inverse = &#8220;true&#8221; to one of the entities will solve the problem<\/p>\n<p>For inverse = &#8220;true&#8221; in NHibernate, refer to this link:&nbsp;<a href=\"https:\/\/mkyong.com\/hibernate\/inverse-true-example-and-explanation\/\">https:\/\/mkyong.com\/hibernate\/inverse-true-example-and-explanation\/<\/a><\/p>\n\n\n<p>It&#8217;s also possible to fix this issue by setting up both one-to-many and many-to-one relationships between 2 entities.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This issue occurred when There are two entities, same class, same table, different entity names. Both entities have one-to-many relationship to a child table Both one-to-many relationships specify the foreign key column as not-null=&#8221;true&#8221; Try to call Session.Merge on one entity, with additional new child entities inside. After trying random configurations, somehow removing not-null=&#8221;true&#8221; from &hellip; <a href=\"https:\/\/bruceng.com\/dev\/?p=521\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;NHibernate: Unable to resolve property: _Property&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[76],"class_list":["post-521","post","type-post","status-publish","format-standard","hentry","category-problems","tag-nhibernate"],"_links":{"self":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=521"}],"version-history":[{"count":3,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/521\/revisions"}],"predecessor-version":[{"id":780,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/521\/revisions\/780"}],"wp:attachment":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}