开发者

NHibernate "illegal access to loading collection" error

开发者 https://www.devze.com 2022-12-12 01:26 出处:网络
What is the reason of this error? My class is Course and it has notes. Mapping is as below. Any idea?

What is the reason of this error? My class is Course and it has notes. Mapping is as below. Any idea?

<bag name="Notes" table="NOTE" cascade="all">
      <key column="COURSEID"/>
      <one-to-many class="Server.Data.Note, Server开发者_Go百科.Data"/>
    </bag>


<bag name="Notes" table="NOTE" cascade="all" inverse="true">
      <key column="COURSEID"/>
      <one-to-many class="Server.Data.Note, Server.Data"/>
    </bag>

inverse="true" solves my problem :)


I my case the reason was that I was mapping a list to an abstract type (during a refactoring). When I changed the class from being abstract, it worked.


In my case the reason was that I converted an int to an enum (public enum FieldType : int { }).

Somehow, that convertion made an error jump where a Field had no Question. I made Question_id not nullable directly in the db, and removed the Fields with null question_id... and the error disappeared. (Replaced by another one, Can't parse 32 as int.. But still, improvement. I think the db type needs to be different.)

"Any sufficiently advanced technology is indistinguishable from magic."

0

精彩评论

暂无评论...
验证码 换一张
取 消