Hi Sergey, here is the SaveContent code,
Code:
public void saveContent(Content c)
{
ISession session = null;
ITransaction tx = null;
try
{
session = factory.OpenSession();
tx = session.BeginTransaction();
session.SaveOrUpdate(c);
tx.Commit();
session.Close();
}
catch (Exception ex)
{
tx.Rollback();
// handle exception
System.Diagnostics.Debug.WriteLine("exception: " + ex);
}
finally
{
session.Close();
}
}
And here is the mapping code...
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="MyProject.Content, MyProject" table="content">
<id name="ContentId" column="content_id" type="Int32" unsaved-value="-1">
<generator class="native" />
</id>
<property name="Title" column="title" />
<property name="Summary" column="summary" />
<property name="StartDate" column="start_date" />
<property name="EndDate" column="end_date" />
<property name="Active" column="active" />
<property name="ContentTypeId" column="content_type_id" />
<bag name="Links">
<key column="content_id"/>
<one-to-many class="MyProject.Link, MyProject"/>
</bag>
<bag name="Images" table="image">
<key column="image_id"/>
<composite-element class="MyProject.Image, MyProject">
<property name="Filename" column="filename" />
<property name="Title" column="title"/>
</composite-element>
</bag>
<bag name="ContentTexts">
<key column="content_id"/>
<one-to-many class="MyProject.ContentText, MyProject"/>
</bag>
</class>
</hibernate-mapping>
And the inner exception is
{"SQL update or deletion failed (row not found)" }
Thanks for your help!