I have uni directional many-to-many relation; Person *... * Address. i have a joined table PersonAddress which holds just the id of Person and Address. Relation is uni-directional; from Person to Address only. When i add address to Person or remove address to Person, it's not persisted. I have my mapping file below:
Person mapping file
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Domain.Person, Domain" table="Person" lazy="false">
<id name="ID" column="ID" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Name" column="Name"/>
<bag name="Addresses" lazy="false" table="PersonAddress" cascade="all">
<key column="PersonId"/>
<many-to-many column="AddressId" class="Domain.Address, Domain"/>
</bag>
</class>
</hibernate-mapping>
Address mapping file
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Domain.Address, Domain" table="Address" lazy="false">
<id name="ID" column="ID" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Name" column="Name"/>
</class>
</hibernate-mapping>
i tried googling and found this
http://technicalmumbojumbo.wordpress.com/2007/09/25/investigating-hibernate-associations-many-to-many/ but it's in java. i tried it as well but it's not working; i can't persist addition and deletion of address of person from person class. any thoughts?