开发者

NHibernate "illegal access to loading collection" error

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜