Hi,
i am a new user of NHibernate.
I have a problem with Cascade Update on 1-Many relations.
How do i implement it? I have 2 tables:
Customers:
   CustomerID-nchar(5)-Primary Key,
   CompanyName-nvarchar(40),
   ContactName-nvarchar(30)-Unique Key,
   Address-nvarchar(60)
   City-nvarchar(15)
   Region-nvarchar(15)
   PostalCode-nvarchar(10)
  
Orders
   OrderID-GUID-PrimaryKEy
   CustomerID-Foreign Key ref Customers(CustomerID)
   OrderDate
   ShippedDate
   ShipAddress
   SHipCity
   ShipRegion
   ShipPostalCode
   CustName-ref Customers(ContactName)
If i update the Parent table Customers i need the child table also to be updated i.e if i update the ContactName in Customers table then i need the CustName in Orders table also be updated for the respective CustomerID.
Please let me know how do i do it?
Here is my Customers.hbm.xml file
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
	<class name="nhibernator.BLL.Customer, nhibernator" table="Customers">
		<!-- map the id field -->
		<composite-id>
			<key-property name="CustomerID" column="CustomerID" type="String" length="20"> 
				<generator class="assigned" /> 
			</key-property>
			<key-property name="ContactName" column="ContactName" type="String">
				<generator class="assigned" />
			</key-property>
		</composite-id>
		<!-- Map properties I'd like to persist/fetch, assume column = propery name, and type is determined by reflection -->
		<property name="CompanyName"/> 
		<property name="Address"/>
		<property name="City"/>
		<property name="Region"/>
		<property name="PostalCode"/>
		<!-- Orders collection, pull customer orders but, loading lazy to minimize load time, resource usage. -->
		<!--<set name="Details" cascade="all" table="CustomerDetails" lazy="true">
			<key column="CustomerID"/>
			<one-to-many class="nhibernator.BLL.Details, nhibernator"/>
		</set>-->
		<bag name="Orders" cascade="all" lazy="true">
			<key column="CustomerID"/>
			<one-to-many class="nhibernator.BLL.Order, nhibernator"/>
		</bag>
	</class>
</hibernate-mapping>
Here is my Orders.hbm.xml file
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
	<class name="nhibernator.BLL.Order, nhibernator" table="Orders">
		<id name="OrderID" type="Int32" unsaved-value="0"> 
			<generator class="identity" /> 
		</id> 
		<property name="CustomerID" length="20"/> 
		<property name="OrderDate" type="DateTime"/> 
		<property name="ShippedDate" type="DateTime"/>
		<property name="ShipName"/>
		<property name="ShipAddress"/>
		<property name="ShipCity"/>
		<property name="ShipRegion"/>
		<property name="ShipPostalCode"/>
		<set name="Products" table="[Order Details]">
			<key column="OrderID"/>
			<many-to-many class="nhibernator.BLL.Product, nhibernator" column="ProductID"/>
		</set>
		<!--<many-to-one name="OCustomer" class="nhibernator.BLL.Customer,nhibernator" column="CustomerID"/>-->
	</class>
</hibernate-mapping>
Please let me know what changes should i make to make it work.
Quote:
[code][/code]