Hi!
I receive a NHibernate.MappingException with message 'collection was not an association: Ikaros.WeekReport.Server.BusinessEntities.Report.reportReadBy' when using a composite-element within a map, but not when I use a simple element.
I have this:
Code:
public class Report {
...
private IDictionary<ReportLineHeader, String> lines = new Dictionary<ReportLineHeader, String>();
public virtual IDictionary<ReportLineHeader, String> Lines
{
get { return lines; }
set { lines = value; }
}
private IDictionary<User, ReportReadByUser> reportReadBy = new Dictionary<User, ReportReadByUser>();
public virtual IDictionary<User, ReportReadByUser> ReportReadBy
{
get { return reportReadBy; }
set { reportReadBy = value; }
}
}
And mappings for the Report class:
Code:
<map name="lines" access="field" cascade="all-delete-orphan" inverse="false" lazy="true" table="ReportLine">
<cache usage="read-write" />
<key column="ReportId" />
<index-many-to-many class="ReportLineHeader" column="ReportLineHeaderId" />
<element column="Body" type="String" not-null="true" length="4000" />
</map>
<map name="reportReadBy" access="field" cascade="all-delete-orphan" lazy="true" table="ReportReadByUser">
<cache usage="read-write"/>
<key column="ReportId" />
<index-many-to-many class="User" column="UserId" />
<composite-element class="ReportReadByUser">
<property name="Date" not-null="true" />
<property name="AsManager" not-null="true" />
</composite-element>
</map>
For some reason the first mapping works, but the second doesn't work for me. The first mapping was using a composite-element at first as well, changing it to use a element fixed the problem. Unfortunately I can't do the same with the second mapping since it has two properties.
I'm using NHibernate 1.2.0.GA.
Any help would be very much appreciated!
BR // Peter