Hi Archie, Archie wrote: > hello Thomas, > Is there documentation about using DListImpl to > support polymorphic?
DLIst is an required ODMG feature. SO it's meant to be used by ODMG apps only. DLists support store *any* persistent objects. Of course it it possible to use all "simple" collection types in OJB to store polymorphic objects. That is objects with a common super-class or super-interface. > Or this feature just works in > odmg api? how about other api? If you have a look at the code of DListImpl you will see how easy it is to write such a collection > > By the way, one feature in Hinbernate impress me is > that it has a type called "class" to store the field's > class as string (java.lang.getClass()). Only with a > feild's class stored in a row, it is possible to > implement ploymorphic. We have the same feature to store objects of different classes in one table. (see tutorial3) > With serializable object stored > as binary, much informatin is lost for doing query > (for example, I just want query elements with some > specific class in a containing object). Am I right? We have to differentiate between polymorphism (objects of different types but with a persistent super-class or super-interface) vs. different classes without persistent superclass or interface. As mentioned above OJB provides full support for polymorphism out of the box. SO there is no need to use Identities for these things. If you want to references to arbitrary classes you will need some kind of persistent pointer mechanism. storing serialized Identities is such a mechanism. query performance is not affected by this mechanism, as all queries are performed as normal SQL queries against the DB. cu, Thomas > Another issue I met in mapping is when using nested > field I must force my code to declare intermediate > fields as concrete class, for example, > InterfaceImpleClass instead of Interface. Otherwise, > an error will happen when retrieving object from > database. I search the mail list archive, Rice had > posted a solution. But I still have this problem in > rc4. > > Finally, I must say 'thank you' to all of you to > provide OJB. I like it (though I seem raising too many > mapping problems). I have used other commercial JDO > compatiable products and I found they also have > similar mapping problems. For OJB, it does quite good > in OR mapping. For Hibernate, I do not like it much > because it force me to wirte many setXXX methods for > properties that should be read-only. For OJB, its > instrumenation to object models is not much since the > introduction of anonymous fields. > > cheers > Archie > > > hello Rice, > Could you mail me the solution to the problem I > mentioned in the above? > > thank you > Archie > > >>>Just have a look at the >>>o.a.ojb.odmg.collections.DListImpl class. >>>It is a list implementation that can hold elements >>>of arbitrary persistent >>>classes. >>> >>>The trick is that we store serialized Identity >>>objects as "pointers" to the >>>actual objects. >>>If you look at the DListImpl code you will see how >>>easy it is. > > > > > > --- Rice Yeh <[EMAIL PROTECTED]> 的訊息:> Hi Thomas, > >> I am not familiar with ODMG but I will go to study >>it. One question needs your help, is it meant that >>in >>the mapping file for this DListImpl I do not need to >>configure the attribute element-class-ref for >>collection-descriptor tag? >> >>Regards, >>Rice >> >>--- Mahler Thomas <[EMAIL PROTECTED]> >>wrote: >> >>>Hello Rice, >>> >>> >>> >>>>Hi, >>>> I have been using OJB for some period. I am >>> >>>taking a >>> >>>>project left by a partner that uses Hinbernate >> >>for >> >>>>persistence. So I start studying Hibernate. >>> >>>Hibernate >>> >>>>has a mapping function called "any type mapping" >>> >>>that >>> >>>>is defined as the follows: >>>> >>>>"The <any> mapping element defines a polymorphic >>>>association to classes from multiple tables. >> >>This >> >>>type >>> >>>>of mapping always requires more than one column. >>> >>>The >>> >>>>first column holds the type of the associated >>> >>>entity. >>> >>>>The remaining columns hold the identifier. It is >>>>impossible to specify a foreign key constraint >> >>for >> >>>>this kind of association, so this is most >>> >>>certainly >>> >>>>not meant as the usual way of mapping >>> >>>(polymorphic) >>> >>>>associations." >>>> >>>>This kind of mapping is quite useful when >> >>dealing >> >>>with >>> >>>>fields of java.lang.Object or interface. >> >>However, >> >>>as I >>> >>>>know, there is no such support in OJB. >>> >>>That's not true! >>>OJB allows to build completely polymorphic >> >>mappings. >> >>>Just have a look at the >>>o.a.ojb.odmg.collections.DListImpl class. >>>It is a list implementation that can hold elements >>>of arbitrary persistent >>>classes. >>> >>>The trick is that we store serialized Identity >>>objects as "pointers" to the >>>actual objects. >>>If you look at the DListImpl code you will see how >>>easy it is. >>> >>>cheers, >>>Thomas >>> >>> >>> >>>>I try to study >>>>the source code of OJB, but am still not able to >>>>figure out the way to modify it (The xml mapping >>>>handling code is a little hard to understand, >> >>just >> >>>>wonder if it is possible to re-write it with >> >>Jibx >> >>>to >>> >>>>make it more concise). >>>> >>>>Regards, >>>>Rice >>>> >>>> >>>>__________________________________ >>>>Do you Yahoo!? >>>>Exclusive Video Premiere - Britney Spears >>>>http://launch.yahoo.com/promos/britneyspears/ >>>> >>>> >>> > --------------------------------------------------------------------- > >>>>To unsubscribe, e-mail: >>> >>>[EMAIL PROTECTED] >>> >>>>For additional commands, e-mail: >>> >>>[EMAIL PROTECTED] >>> >>> >>> > --------------------------------------------------------------------- > >>>To unsubscribe, e-mail: >>>[EMAIL PROTECTED] >>>For additional commands, e-mail: >>>[EMAIL PROTECTED] >>> >> >> >>__________________________________ >>Do you Yahoo!? >>Protect your identity with Yahoo! Mail AddressGuard >>http://antispam.yahoo.com/whatsnewfree >> >> > > --------------------------------------------------------------------- > >>To unsubscribe, e-mail: >>[EMAIL PROTECTED] >>For additional commands, e-mail: >>[EMAIL PROTECTED] >> > > > ----------------------------------------------------------------- > 每天都 Yahoo!奇摩 > 海的顏色、風的氣息、愛你的溫度,盡在信紙底圖 > http://tw.promo.yahoo.com/mail_premium/stationery.html > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
