AW: [Objectbridge-developers] optional relationships
Brought to you by:
thma
From: Mahler T. <tho...@it...> - 2001-08-10 06:41:51
|
Hi Dirk, > -----Urspr=FCngliche Nachricht----- > Von: Dirk Olmes [mailto:di...@xa...] > Gesendet: Freitag, 10. August 2001 06:55 > An: David Forslund > Cc: obj...@li... > Betreff: Re: [Objectbridge-developers] optional relationships >=20 >=20 > David Forslund wrote: >=20 > > > To illustrate things better I'll just give a short=20 > description of my > > > tables: I have a table 'Person' which has a to-many=20 > relationship to > > > the table 'Folder'. The 'Folder' table will later have a = reflexive > > > relationship to itself (so I can have subfolders to every = folder). > > > (BTW: is that possible with ObjectBridge right now?) > >=20 > > Yes, it does. We are using it this way now. One of my=20 > applications > > has the same structure. It has an "Identity: object which=20 > contains many > > "Traits" Traits can contain other Traits. I have two=20 > tables Identity and Trait > [...] > > > In order to model that, the 'Folder' table needs a=20 > foreign key which > > > can be NULL for the case that a folder has no parent folder. > >=20 > > In my case I don't allow for a Trait to exist by itself, so a Trait > > has a Trait or an Identity as a parent. I don't formally=20 > use a foreign key. >=20 > Good to hear that. But how do you do the mapping? I currently have no > idea how to accomplish that without a foreign key. Or do you put code > into Trait to retrieve the parent? >=20 There is sample code for reflexive Joins in package test.ojb.broker = have a look at classes Tree and TreeGroup and there respective mappings. The Junit test for this resides in class TreeTest. You will see that the root nodes of the trees don't have entries for a parentId while the child nodes have. You find the respective mappings in the repository.xml file. I don't see how the formal usage of a foreign key in the database = schema could cause problems?! HTH Thomas > -dirk >=20 > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > http://lists.sourceforge.net/lists/listinfo/objectbridge-developers >=20 |