Re: [Objectbridge-developers] RE: [objectbridge - Open Discussion] Polymorphism support?
Brought to you by:
thma
From: David F. <dw...@la...> - 2001-02-01 00:28:30
|
At 04:41 PM 1/31/2001 +0100, Mahler Thomas wrote: >Hi Sascha, > > > -----Urspr=FCngliche Nachricht----- > > Von: nobody [mailto:no...@so...] > > Gesendet: Dienstag, 30. Januar 2001 22:31 > > An: no...@so... > > Betreff: [objectbridge - Open Discussion] Polymorphism support? > > > > > > Read and respond to this message at: > > http://sourceforge.net/forum/message.php?msg_id=3D103071 > > By: koenig > > > > Hi, > > > > I looked into ObjectBridge as a O/R mapping tool for our OpenEMed= project > > (http://telemed.lanl.gov/OpenEMed). > > >Thanks for your interest! It would be a great opportunity to proof the >usability of OJB if it could solve your persistence needs. > > > Unfortunately I didn't found a mechanism for supporting polymorph > > objects. > >You are right. As of today there is no support for Polymorphism. >But of course it is an essential feature. It is also required by the ODMG >spec. >If it is a feature you need urgently I can start to work on it immediately. > >I have already a design in mind, so it will take only a few days... We urgently need this feature. Our only other option in open source is= castor. > > > > In particular: > > Our main class has a field 'value' of an interface type. This > > interface type > > is implemented by several concrete classes that get stored in the > > 'value' field > > of the main object. > > I'd like to store these objects in separate tables referenced > > from the main > > object, but even storing them as embedded objects would be fine. > > > > Is there a way to do this with ObjectBridge? > >As long as I'm not finished with a real solution, you could try the >following: >you can use an additional field 'valueOID' of type String which takes a >serialized >representation of the concrete values Identity: >valueOID =3D new Identity(value).serialize(); >instead of making the field value persistent you store the serialized OID= in >a db column. >Of course your value field is then transient. On loading your Object you >have to reconstruct it e.g. in a constructor by: >value =3D (YourInterface) >broker.getObjectByIdentity(Identity.forName(valueOID)); > >I'm using this approach for untyped Collections (like org.odmg.DList) and= it >works quite well. But of course it's not type safe and brings one= additional >level of indirection into the mapping... > >Of course you can also store complete serialized "embedded" objects in a >single db column, but this is even worse from a design point of view... The difficulty with what you suggest is that we are trying to do all of=20 this through an interface that lets us talk to multiple database sources. So we need a= =20 "generic" solution that we don't have to wire much into our objects. We are willing to do=20 some specializations (such as implementing the Persistent interface), but don't like to have to get into= =20 the details of the objects much. Thanks, Dave >best regards, > >Thomas > > >_______________________________________________ >Objectbridge-developers mailing list >Obj...@li... >http://lists.sourceforge.net/lists/listinfo/objectbridge-developers David W. Forslund dw...@la... Computer and Computational Sciences http://www.acl.lanl.gov/~dwf Los Alamos National Laboratory Los Alamos, NM 87545 505-665-1907 FAX: 505-665-4939 |