Scenario: An existing product line, adding new traffic line to that
product line. Attaching the children (traffic lines) to the existing
product line through helper:

ProductLine 1:M TrafficLine

newTrafficLine.ProductLine = this;   //associating the child with the
parent
_productLine.TrafficLines.Add(newTrafficLine);

I now want to show the new list of newly created traffic lines on the
web page, with the newly generated ids displayed of the traffic lines:

#          StartDate      Amount
0          1/1/2008       100
0          2/1/2008       125

In stead of seeing the newly generated ids I only see the 0. When I
perform a save directly on the child it does return the new child's id
from the DB, like so:

_trafficLineDao.Save(newTrafficLine);

Why does it not perform the select to retrieve the newly generated id
when I SaveOrUpdate on the parent (product line)?

My mapping looks like so:
PARENT:
--------------
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="MyDomain" namespace="MyDomain" >
        <class name="ProductLine" table="ProductLine">

                <id name="Id" column="Id" type="int">
                        <generator class="native">
                        </generator>
                </id>
                <many-to-one name="Traffic" class="Traffic" 
column="TrafficId"></
many-to-one>

                <list name="TrafficLineList" table="TrafficLine" 
cascade="all-delete-
orphan" lazy="true" inverse="true">
                        <key column="ProductLineId" />
                        <list-index column="SortIdx"></list-index>
                        <one-to-many class="TrafficLine" />
                </list>
        </class>
</hibernate-mapping>

CHILD:
----------
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="MyDomain" namespace="MyDomain" >
        <class name="TrafficLine" table="TrafficLine">

                <id name="Id" column="Id" type="int" >
                        <generator class="native">
                        </generator>
                </id>
                <property name="StartDate" column="StartDate"></property>
                <property name="Amount" column="Amount"></property>
                <many-to-one name="ProductLine" class="ProductLine"
column="ProductLineId" not-null="true"></many-to-one>
        </class>
</hibernate-mapping>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to