thanks morten, that does help

On Nov 11, 6:35 pm, "Morten Maxild" <[email protected]> wrote:
> You can subclass components, but you can't specify in mappings which base 
> class to instantiate when dehydrating. This can only be done with persistent 
> classes (table per hierarchy etc...). Therefore must people would say 
> components do not support inheritance.
>
> But you can work around this using a custom type (IUserType, 
> ICompositeUserType) that encapsulates the factory behaviour, and I am sure 
> other techniques is available too. The key is factoring out the polymorphic 
> behaviour with the least amount of state (I prefer stateless, maybe using 
> double dispatch)
>
> HTH
> Morten
>
> >-----Original Message-----
> >From: [email protected] [mailto:[email protected]] On Behalf
> >Of Jason Meckley
> >Sent: Wednesday, November 11, 2009 7:03 PM
> >To: nhusers
> >Subject: [nhusers] Re: Which is better to use Component Mapping or
> >Collection Mapping NHibernate?
>
> >"Component mapping is just for prettying up your object because it
> >makes no change to how the data is stored."
>
> >more than "pretty" code. you can add behavior to a component (class).
> >I believe you can also subclass components.
> >here is a simple example.
>
> >On Nov 11, 11:27 am, J M <[email protected]> wrote:
> >> Just to elaborate a bit.
>
> >> Component mapping is 1-to-1, and for the most part, collection mapping
> >> is 1-to-n (can also by 1-to-1).
>
> >> As an example, if you have a user and they only have one address, you
> >> might map the address as a component and access it like:
>
> >> city = user.Address.City
> >> instead of:
> >> city = user.City
>
> >> Component mapping is just for prettying up your object because it
> >> makes no change to how the data is stored.
>
> >> If your user can for whatever reason have 10 addresses, then it would
> >> it much better to map as a collection. You would then access it
> >> through the collection, something like:
>
> >> city = user.Addresses[0].city
>
> >> On Nov 11, 1:51 am, Dick Negrana <[email protected]> wrote:
>
> >> > thanks oskar...
>
> >> > On Wed, Nov 11, 2009 at 8:23 AM, Oskar Berggren
> ><[email protected]>wrote:
>
> >> > > Hmm... you seem to think that these are interchangeable concepts.
> >They
> >> > > are not. You use both, depending on what you need.
>
> >> > > If your entity contains a collection, you use "collection mapping".
> >If
> >> > > you entity has a property that is of another ("small") class, and you
> >> > > don't want to map that to a separate table, use "component mapping".
>
> >> > > /Oskar
>
> >> > > 2009/11/11 Dick Negrana <[email protected]>:
> >> > > >  I just want to know which is appropriate to use in mapping a
> >entity?
> >> > > > Collection Mapping or Component Mapping in NHibernate 2.0
>
> >> > > > On Tue, Nov 10, 2009 at 4:47 PM, Oskar Berggren <
> >> > > [email protected]>
> >> > > > wrote:
>
> >> > > >> 2009/11/10 silentdk <[email protected]>:
>
> >> > > >> > Guys,
>
> >> > > >> > I was confused which I going to use in Mapping my entity. Anyone
> >can
> >> > > >> > give me idea which is better. Component or Collection Mapping?
>
> >> > > >> Ehm... not sure I understand you correctly. Those are quite
> >different
> >> > > >> things. Which is better, a hammer or a saw?
>
> >> > > >> /Oskar
--~--~---------~--~----~------------~-------~--~----~
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