NHibernate "illegal access to loading collection" error
Asked Answered
W

3

6

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.Data"/>
    </bag>
Weisbrodt answered 23/11, 2009 at 15:12 Comment(0)
W
2
<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 :)

Weisbrodt answered 23/11, 2009 at 16:12 Comment(0)
H
2

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.

Hump answered 28/4, 2010 at 6:25 Comment(0)
B
0

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."

Backdrop answered 22/6, 2011 at 10:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.