From: Alexandru Popescu Date: 2005-10-27T06:14:22+09:00 Subject: Re: The "perfect" ORM? #: rubyhacker@gmail.com changed the world a bit at a time by saying on 10/26/2005 9:52 PM :# > Alexandru Popescu wrote: >> I've been working with Hibernate for quite a while and imo it is correctly >> approaching so called >> object - relational mismatch. >> >> The real good thing about this approach is that it is not obtrusive in any ways with your domain >> model objects and it let's you focus and work only on the objectual world. > > That sounds good so far. > >> On the dark side of the problem: you should provide in some way the mapping between the object world >> and the relational world. > > Yes, that is a necessary evil. Naturally I want the toolkit to be as > smart > as possible, and its usage to be painless as possible. > >> While there are a few things that could be a little simplified (like >> automatic type conversions), the big problem is the impossibility to use this simplified form on >> relationships. If the parametrized types would have been implemented without the erasure mechanism >> than this simplification could be brought further, but for the moment we have to use some other way >> to describe relations: and here comes into play the metadata. > > That sounds interesting, but I did not understand any of it. :) I am > not > sure what you mean by parametrized types, or what an erasure mechanism > is. > He he... no problem. Probably I can help here. Considering a small example Foo has a 1 - N relation with Bar. In your objectual world, considering that you would like/need to have both way navigation you should have class Foo { List myBars; } class Bar { Foo myParentFoo; } List is a parametrized type; List is a collection whose elements are Bar-s. Having this strongly typed you could do some magic and don't have to describe through metadata the relation between Foo and Bar. Unfortunately the java compiler is removing the Bar part, so you are left with a untyped collection => there is not way to know that Foo has some relation to Bar. >> There are a few different approaches >> used: metadata through external XML, metadata through javadoc comments and lately metadata through >> annotations. > > All of these seem wrong to me. My approach will be: Metadata through > Ruby code > external to the stored objects. > Even if you accept it or not this is still metadata and the format is more or less same verbose (at least for me). I would probably agree that maybe in Ruby this makes sense, but to do this on Java would be plain wrong ;-). ./alex -- .w( the_mindstorm )p. > I will try to give an example in a week or so. > > > Thanks, > Hal > > >