AW: [Objectbridge-developers] Sample Many-to-Many Mapping XML
Brought to you by:
thma
From: Mahler T. <tho...@it...> - 2001-05-31 07:49:44
|
Hi all, > -----Urspr=FCngliche Nachricht----- > Von: Christian Sell [mailto:chr...@ne...] > Gesendet: Mittwoch, 30. Mai 2001 00:22 > An: obj...@li... > Betreff: Re: [Objectbridge-developers] Sample Many-to-Many Mapping = XML >=20 >=20 > Hi Thomas and all, >=20 > as this touches one of my pet subjects ;-), I have to raise=20 > my voice here: >=20 > >Right now this is exactly the thing you have to do! You need=20 > three tables > to > >decompose m-n into two 1-n relationships. Thus you also need=20 > three classes. > >This approach is also suggested by the gurus: see > >ftp://members.aol.com/kgb1001001/Chasms/chasms.pdf. >=20 > Now what exactly makes someone a "guru"? Writing an article=20 > like that one? I > think figuring out that you have to introduce an intermediary=20 > entity for an > N-M relationship (unless your O/R tool handles them=20 > transparently) does not > require deep understanding - its simply the only way to get=20 > there, as it > directly reflects the table structure. I did not want to say that using 3 classes direcly reflecting the table structure is "the holy gral" of O/R mapping. I just mentioned the = crossing chasms pattern language as it presents a widely accepted approach. Rock solid commercial products like TopLink are based on their = insights. There are even OO databases like Objectivity that use Relationship = classes for modelling m-n relationships. Of course OJB aims to incorporate everything a OO designer/developer = needs to build well designed applications.=20 It would be cool to have the m-n mechanisms completely hidden in the persistence layer! Say we have classes User and Role with an M-N relationship as given by Sasha's example. It will be relatively easy to hide the functionality of the UserRoleRelationship class in the OJB framework. Now imagine we have an attributed Relationship (UML allows to model = such things!) between User and Role. The Relationship has an attribute = boolean isDefault, that is true for a users default role and false for all = other roles. You will have to place this attribute into the USER_ROLE table as it is = an individual attribute of each relationship. I don't see how such attributed relationships could be cleanly modelled without a UserRoleRelationship class. Do you have any ideas how OJB could automatically handle such a = situation?=20 cheers, Thomas >=20 > just my 2c, as always > Christian >=20 >=20 > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > http://lists.sourceforge.net/lists/listinfo/objectbridge-developers >=20 |