As you can see bellow, I add five lines (LINIES_EXPEDICIO table) into a document (EXPEDICIONS table)
Quote:
NHibernate: INSERT INTO EXPEDICIONS (DATA, NUM_EXPEDICIO, NUM_BULTOS, ALBARA, CLIENT, DIRECCIO_ENTREGA, TRANSPORTISTA, EXPEDICIO) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7); @p0 = '31/07/2007 8:33:08', @p1 = '0', @p2 = '0', @p3 = '20', @p4 = ' 2', @p5 = '31', @p6 = '', @p7 = '4'
NHibernate: INSERT INTO LINIES_EXPEDICIO (ARTICLE, QUANTITAT, EXPEDICIO, LINIA) VALUES (@p0, @p1, @p2, @p3); @p0 = ' 139', @p1 = '100', @p2 = '4', @p3 = '0'
NHibernate: INSERT INTO LINIES_EXPEDICIO (ARTICLE, QUANTITAT, EXPEDICIO, LINIA) VALUES (@p0, @p1, @p2, @p3); @p0 = ' 139', @p1 = '100', @p2 = '4', @p3 = '1'
NHibernate: INSERT INTO LINIES_EXPEDICIO (ARTICLE, QUANTITAT, EXPEDICIO, LINIA) VALUES (@p0, @p1, @p2, @p3); @p0 = ' 139', @p1 = '49', @p2 = '4', @p3 = '2'
NHibernate: INSERT INTO LINIES_EXPEDICIO (ARTICLE, QUANTITAT, EXPEDICIO, LINIA) VALUES (@p0, @p1, @p2, @p3); @p0 = ' 140', @p1 = '200', @p2 = '4', @p3 = '3'
NHibernate: INSERT INTO LINIES_EXPEDICIO (ARTICLE, QUANTITAT, EXPEDICIO, LINIA) VALUES (@p0, @p1, @p2, @p3); @p0 = ' 140', @p1 = '52', @p2 = '4', @p3 = '4'
NHibernate: UPDATE EXPEDICIONS SET DATA = @p0, NUM_EXPEDICIO = @p1, NUM_BULTOS = @p2, ALBARA = @p3, CLIENT = @p4, DIRECCIO_ENTREGA = @p5, TRANSPORTISTA = @p6 WHERE EXPEDICIO = @p7; @p0 = '31/07/2007 8:33:08', @p1 = '0', @p2 = '0', @p3 = '20', @p4 = ' 2', @p5 = '31', @p6 = '', @p7 = '4'
NHibernate: UPDATE LINIES_EXPEDICIO SET ARTICLE = @p0, QUANTITAT = @p1 WHERE EXPEDICIO = @p2 AND LINIA = @p3; @p0 = ' 139', @p1 = '100', @p2 = '4', @p3 = '0'
NHibernate: UPDATE LINIES_EXPEDICIO SET ARTICLE = @p0, QUANTITAT = @p1 WHERE EXPEDICIO = @p2 AND LINIA = @p3; @p0 = ' 139', @p1 = '100', @p2 = '4', @p3 = '1'
NHibernate: UPDATE LINIES_EXPEDICIO SET ARTICLE = @p0, QUANTITAT = @p1 WHERE EXPEDICIO = @p2 AND LINIA = @p3; @p0 = ' 139', @p1 = '49', @p2 = '4', @p3 = '2'
NHibernate: UPDATE LINIES_EXPEDICIO SET ARTICLE = @p0, QUANTITAT = @p1 WHERE EXPEDICIO = @p2 AND LINIA = @p3; @p0 = ' 140', @p1 = '52', @p2 = '4', @p3 = '4'
So, later I have removed the line number 3 from collection. In order to do it, I perform this code:
Code:
private void remove_linia_kernel (Model.Linia_Expedicio linia)
{
linia.Expedicio = null;
this.linies.Remove(linia);
}
public virtual void remove_linia (Model.Linia_Expedicio linia)
{
if (this.linies.Contains(linia)) this.remove_linia_kernel(linia);
}
So, I hope when this document is updated, the line number 3 is deleted also. Now, NHibernate updates other lines, but doesn't delete line 3.
What do I do wrong?
Thanks for all.
Mappings-->
Code:
<class name="Model.Expedicio, Model" table="EXPEDICIONS">
<id name="Codi" column="EXPEDICIO" type="Int32" unsaved-value="-1">
<generator class="increment"/>
</id>
<property name="Data" column="DATA" type="DateTime"/>
<property name="Num" column="NUM_EXPEDICIO" type="Int32"/>
<property name="Bultos" column="NUM_BULTOS" type="Int32"/>
<many-to-one name="Albara" class="Model.Albara, Model" column="ALBARA" lazy="false"/>
<many-to-one name="Client" class="Model.Client, Model" column="CLIENT" lazy="false"/>
<many-to-one name="Direccio_entrega" class="Model.Direccio, Model" column="DIRECCIO_ENTREGA" lazy="false"/>
<many-to-one name="Transportista" class="Model.Transportista, Model" column="TRANSPORTISTA" lazy="false"/>
<set name="Linies" cascade="all" inverse="true" lazy="false">
<key column="EXPEDICIO"/>
<one-to-many class="Model.Linia_Expedicio, Model"/>
</set>
</class>
<class name="Model.Linia_Expedicio, Model" table="LINIES_EXPEDICIO">
<composite-id name="Codi" class="Model.Linia_Expedicio_PK, Model">
<key-many-to-one name="Expedicio" class="Model.Expedicio, Model" column="EXPEDICIO" lazy="false"/>
<key-property name="Linia" column="LINIA" type="Int32"/>
</composite-id>
<many-to-one name="Article" class="Model.Article, Model" column="ARTICLE" lazy="false"/>
<property name="Quantitat" column="QUANTITAT" type="Int32"/>
</class>