Hello everybody, i'm new with this and i wanted to do an example where a Person has many Friends. So I think is a many-to-many relation. So i made this mapping:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Domain" namespace="Domain">
<class name="Person" table="Person">
<id name="ID" column ="id" type="int" unsaved-value="0">
<generator class="native"/>
</id>
<property name="Name" type="String" column="nombre" not-null="true" length="100"/>
<property name="LastName" type="String" column="apellido" not-null="true" length="100"/>
<property name="Address" type="String" column="direccion" not-null="true" length="200"/>
<property name="Age" type="String" column="edad" not-null="true" length="3"/>
<bag name="Friendships" table="Friendship">
<key column="me_id"/>
<many-to-many column="friend_id"
class="Person"/>
</bag>
</class>
</hibernate-mapping>
And the class definition is the following:
Code:
public class Person
{
public virtual String Name { get; set; }
public virtual String LastName { get; set;}
public virtual String Age {get; set;}
public virtual String Address {get;set;}
public virtual int ID { get; set; }
public virtual IList<Persona> Friendships { get; set; }
public Person()
{
}
}
The problem is that, when i call the method session.Save(person) . The person is inserted but in the table "Friendship" there is no data inserted. May be problem that the "Friends" are already in the "Person" table? Does anybody has an idea of why the middle table (Friendship) is not saving any data?
Thank you