Hi Jan If you want DiscountOrder to be a child component you can get a reference back to its parent order by using the "parent" element inside the "component" element. Then all you have to do is have a property to put it in and NHibernate will do the rest. I think this is what Fabio was eluding to.
Assuming that DiscountOrder has a property of Order that is of type IHaveDiscounts the component mapping might look like this: <component name="DiscountOrder " class="DiscountOrder" > <parent name="Order"/> ... </component> Hope that helps On Sep 25, 11:45 pm, Jan Limpens <jan.limp...@gmail.com> wrote: > I am not sure how this could be mapped ... does nh behave like a di > container in this situation? even though, how would nh know which > instance is the right one? How could I pass > a reference of it's owner to the component? > > 2009/9/25 Fabio Maulo <fabioma...@gmail.com>: > > > > > when you will upload from NH, NH will inject it through property or field > > (depending on your mapping) > > > 2009/9/25 Jan Limpens <jan.limp...@gmail.com> > > >> yes, but how does Discounts get the reference to IHaveDiscounts? > > >> 2009/9/25 Fabio Maulo <fabioma...@gmail.com> > > >>> protected DiscountOrder(){} > > >>> 2009/9/25 Jan Limpens <jan.limp...@gmail.com> > > >>>> I have > > >>>> class Order:IHaveDiscounts > >>>> public Order(){ > >>>> discounts = new DiscountContext(this); > >>>> } > >>>> DiscountContext Discounts > >>>> get { return discounts ;} > > >>>> and > > >>>> class DiscountOrder(IHaveDiscounts discounted) > >>>> ... > > >>>> Order is a mapped entity and I want to use DiscountOrder as a > >>>> component to strip Order from behaviour it should not really own, it's > >>>> becoming WAY to big, anyway. But when I try this NH complains about > >>>> it: > >>>> No default constructor for entity: DiscountContext > > >>>> Is there an easy way around this? Currently I seem to hit my head on > >>>> NH all the time when I try to keep my domain as I think it should be > >>>> :( > > >>>> -- > >>>> Jan > > >>> -- > >>> Fabio Maulo > > >> -- > >> Jan > > > -- > > Fabio Maulo > > -- > Jan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---