On 14 Apr, 17:21, Fabio Maulo <[email protected]> wrote:
> Which is exactly your case is not clear to me btw I'll try to explain you
> one of the bases of ORM tech.
> In ORM we like no-business-meaning-POID (Persistent Object ID).
> A POID may be unique for the whole system but *always is unique in a class
> hierarchy*.
>
> Now...
> To persistent-represent an hierarchy you can use various strategies. What
> you are using is probably table-per-class  where the *state of one
> object*is spanned between more than one table (a table per each
> class).
> class Animal
> class Dog
> class Cat
>
> When I want insert an Dog I'm inserting 2 records in two tables but with the
> same ID because the object-state is only one (a Dog).
> When I want insert an Cat I'm inserting 2 records in two tables but with the
> same ID because the object-state is only one (a Cat).
>
> If you have the class person with a "ICollection<Animal> Pets" NH will
> generate a query with a join between Animal+Dog+Cat and because a POID
> is *always
> is unique in a class hierarchy*, NH can instantiate the correct class (a Dog
> or a Cat).
>
> There is another possible representation of a relation called "Heterogeneous
> Association" (<any>):
> The class person has "ICollection<System.Object> Things". In this case you
> can put whatever entity you want in the collection and, only in this case,
> NH needs two values:
> 1. The class to instantiate
> 2. The POID of the class-to-instantiate hierarchy
>
> http://nhforge.org/doc/nh/en/index.html#collections-heterogeneous
>
> Advise:
> If you are moving from your "homebrew "ORM" solution" to NH don't try to
> re-use the same DB schema... better... don't try to work NH as your "homebrew
> "ORM" solution".
>
> 2010/4/14 Marcus Henriksson <[email protected]>
>
>
>
>
>
> > Hi,
>
> > I have a homebrew "ORM" solution that I want to migrate to nhibernate,
> > but I can't seem to find a solution to the inheritence mapping I use
> > and a matching one i NH.
>
> > Here is what my current solution looks like:
>
> > Example one to many:
>
> > Type1 "1 - *" Type2
>
> > Type2
> >  - Type1Id
> > If there is inheritance on Type1 then in Type2 I have a second FK-
> > field that points to which class it's refering, Type1ClassId. This is
> > the part where my orm finds out how to find the correct table/entity.
>
> > Example many to many:
>
> > Type1 "* - *" Type2
>
> > Type1ToType2
> >  - Type1Id
> >  - Type2Id
> > If inheritance the same goes here
>
> > Type1ToType2
> >  - Type1ClassId
> >  - Type1Id
> >  - Type2ClassId
> >  - Type2Id
>
> > Is there some way this can be mapped in NH?
>
> > also available at
> >http://stackoverflow.com/questions/2637605/strategy-for-migrating-to-...
>
> > --
> > 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.
>
> --
> Fabio Maulo

The thing is that I don't want to use the existing db shceme, i dont
like it, i forgot to mention that in my post, but the
reason I want to map my current scheme is to be able to somehow
convert the old scheme to a new one
via nhibernate, but maybe theres easier ways to do that.

-- 
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