Re: [Objectbridge-developers] RE: [objectbridge - Open Discussion] Polymorphism support?
Brought to you by:
thma
From: Sascha A. K. <Ko...@un...> - 2001-02-01 15:56:21
|
that sounds really good. When do you think you could have a first = version ready? An id for subtables is not a restriction, we would need that anyway if = we don't want to store everything in the main table. Thanks a lot Sascha ----- Original Message -----=20 From: David Forslund=20 To: Mahler Thomas ; objectbridge=20 Sent: Wednesday, January 31, 2001 5:28 PM Subject: Re: [Objectbridge-developers] RE: [objectbridge - Open = Discussion] Polymorphism support? 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 this through=20 an interface that lets us talk to multiple database sources. So we = need a "generic" solution that we don't have to wire much into our objects. We are willing to = do some specializations (such as implementing the Persistent interface), but don't like to have to get = into 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... =20 Computer and Computational Sciences = http://www.acl.lanl.gov/~dwf Los Alamos National Laboratory Los Alamos, NM 87545 = =20 505-665-1907 FAX: 505-665-4939 |