I am having trouble with my many to many mappings being persisted.
Here are my mappings:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="vcf.code.entites.Stand,vcf" table="vcfStands">
<id name="Code" column="code" type="Int32">
<generator class="native"/>
</id>
<set name="Locations" inverse="true" table="vcfLocationLookup">
<key column="stand_id"/>
<many-to-many column="hesa_id" class="vcf.code.entites.classification.Location,vcf"/>
</set>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="vcf.code.entites.classification.Location,vcf" table="vcfLocation">
<id name="Id" column="HESA_id" type="Int32" unsaved-value="0">
<generator class="assigned"/>
</id>
<set name="Stands" table="vcfLocationLookup">
<key column="hesa_id" />
<many-to-many column="stand_Id" class="vcf.code.entites.Stand,vcf" />
</set>
<property column="description" type="String" name="Description" length="255" />
</class>
</hibernate-mapping>
The problem is that when i create a Stand and add some Locations to it, when i then add\update the Stand the lookups are not being added to vcfLoctionLookup. What am i doing wrong?
Code:
foreach(ListItem i in Locations.Items)
{
if(i.Selected)
{
Location l = new Location();
l.Id= Convert.ToInt32(i.Value);
stand.Locations.Add(l);
}
}
standDAO.updateStand(stand);