Why do you need to avoid the bidirectional relationship in the first place? That's the standard way to represent this domain.
Diego On Thu, Apr 15, 2010 at 15:27, Dinesh <[email protected]> wrote: > I would like to Cascade Save operation from Parent to Child without > using the bi-directional relation of having the parent represented as > a property in the Child through Many-to-One relation. Using the class > Order - Orderline example i have setup relation such that > Order.LineItems is defined as a One-to-Many bag with inverse =true. > > <bag cascade="save-update" inverse="true" lazy="true" > name="LineItems"> > <key> > <column name="OrderId" /> > </key> > <one-to-many class="OrderLine" /> > </bag> > > However my OrderLine does not have a relation to Order, but just the > OrderId property > > <property name="OrderId"/> > > Until now i was able to manage with the help of method in Order called > AddLineItem which adds the OrderLine to LineItems collection and also > set the OrderId on the OrderLine. But this approach does not work if > the Order itself is new since OrderId is 0. > > public virtual void AddLineItem(OrderLine item) > { > item.OrderId = Id; > LineItems.Add(item); > } > > Is there any other approach to do cascade inserts without the > bidirectional relation. I want to avoid having bidirectional so that > the Order reference on the child is not used. > > Regards > Dinesh > > -- > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- 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.
