Here's the notification mapping file:-
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="SCF.FMS.DataModel.Notification, DataModel" table="Notification">
<id name="Id" type="Int32" unsaved-value="0">
<column name="NotificationID" sql-type="int" not-null="true" unique="true" index="PK_Notification"/>
<generator class="native" />
</id>
<property name="NotificationSubject" type="String">
<column name="NotificationSubject" length="50" sql-type="varchar" not-null="false"/>
</property>
<property name="NotificationDate" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate">
<column name="NotificationDate" sql-type="datetime" not-null="false"/>
</property>
<property name="NotificationText" type="String">
<column name="NotificationText" length="50" sql-type="varchar" not-null="false"/>
</property>
<property name="NotificationStatus" type="String">
<column name="NotificationStatus" length="50" sql-type="varchar" not-null="false"/>
</property>
<bag name="NotificationReadMarks" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.NotificationReadMark, DataModel"/>
</bag>
<bag name="NotificationSecondaryAddressees" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.NotificationSecondaryAddressee, DataModel"/>
</bag>
<bag name="NotificationPrimaryAddressees" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.NotificationPrimaryAddressee, DataModel"/>
</bag>
<bag name="NotificationNotes" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.NotificationNote, DataModel"/>
</bag>
<bag name="Proposals" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.Proposal, DataModel"/>
</bag>
<bag name="Countries" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.Country, DataModel"/>
</bag>
</class>
</hibernate-mapping>
And here's the primary addresse mapping file:-
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="SCF.FMS.DataModel.NotificationPrimaryAddressee, DataModel" table="NotificationPrimaryAddressee">
<id name="Id" type="Int32" unsaved-value="0">
<column name="NotificationPrimaryAddresseeID" sql-type="int" not-null="true" unique="true" index="PK_NotificationPrimaryAddressee"/>
<generator class="native" />
</id>
<property name="NotificationType" type="String">
<column name="NotificationType" length="50" sql-type="varchar" not-null="false"/>
</property>
<property name="NotificationEmailAddress" type="String">
<column name="NotificationEmailAddress" length="50" sql-type="varchar" not-null="false"/>
</property>
<many-to-one name="Notification" class="SCF.FMS.DataModel.Notification, DataModel">
<column name="NotificationID" sql-type="int" not-null="false"/>
</many-to-one>
<many-to-one name="User" class="SCF.FMS.DataModel.User, DataModel">
<column name="UserID" sql-type="int" not-null="false"/>
</many-to-one>
</class>
</hibernate-mapping>
The update I was performing was on the main notification that contained a child primaryaddressee. The update statement looks like this:-
NHibernate.ISession session = HSession.getSession(); //get handle to current session
session.SaveOrUpdate(objNotificationData);
|