Disposable and generic: "Links to associations not assigned to a class"

TL version of the DR: . The code below gives me an exception to the class of associations without breaking into classes when creating a SessionFactory. What needs to be changed in the code to fix it?


Although Ayende @Rahien does not recommend using class mappings in this 2007 article, I was still in that. I used the approach he mentioned. First a bit that works:

<class name="Review`1[Person]" table="Review">
  <id name="Id" column="ReviewId"><generator class="native" /></id>
  <property name="Rating" />
  <many-to-one name="Subject" column="PersonId" class="Person" />
</class>

The corresponding general class is as follows:

public class Review<T> : BaseEntity where T : IReviewable
{
    public virtual int Rating { get; set; }
    public virtual T Subject { get; set; }
}

, Review MVC- . , Subject , .


Review Person . , :

<class name="Person">
  <!-- abbreviated -->
  <bag name="Reviews" table="Review">
    <key column="PersonId"/>
    <one-to-many class="Review`1[Person]" />
    <!-- Also tried these:
    <one-to-many class="table="Review"> 
    ... plus a few variations with fully qualified names ...
    -->
  </bag>
</class>

() :

public class Person : BaseEntity, IReviewable
{
    /* Abbreviated */
    public virtual IList<Review<Person>> Reviews { get; set; }
}

SessionFactory:

:.... --. class ....

, : ? ? ?

+2
1

:

<class name="NHTest.Review`1[[NHTest.Person, NHTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" table="Review">
  ...
  <many-to-one name="Subject" column="..." />
</class>
<class name="Person">
  ...
  <bag name="Reviews">
    <key column="..." />
    <one-to-many class="NHTest.Review`1[[NHTest.Person, NHTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" />
  </bag>
</class>

, .

+1

All Articles