On Mon, 9 Feb 2004, Gus Heck wrote: > According to the book I have (which is not the spec, but hopefully the > author has read and understood the spec) it has the following example: > > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE jdo SYSTEM "jdo.dtd"> > <jdo> > <package name="com.corejdo.examples.model"> > <class name="Author"> > <field name="books"> > <collection element-type="com.corejdo.examples.model.Book"/> > </field> > </class> > </package> > </jdo> > > This looks like what you are describing, but underneath that with a bold > heading is this: > > Additional Metadata > > The additional metadata shown for the "books" filed is optional; it > does not need to be specified. If not specified the JDO runtime assumes > that the colledtion may contain a reference to any persistent object, as > does normal Java. > Even though it is optional it is best practice to define the element > type of a collection because it potentially allows the JDO runtime ot > optimize how it handles the field both in-memory as well as in the > datastore.
The spec certainly has object-oriented or object-based databases/repositories in mind which probably store the associations explicitly. In OJB this (currently) can only be achieved via the indirection table. However this requires either one table for each type pair of the ends of the association, or the definition of the association between base types of the possible objects at both ends. As the first way is pretty difficult to handle, my guess is that for the combination OJB+JDO you currently need this - for the spec - optional data. Perhaps some JDO expert can hop in and explain in more detail. > From this it looks like "PersistenceCapable" is supposed to be the > default common base type. So for my project, given the current OJB > implementation is not the final implementation and it seems in this > respect incomplete, I will probably just have to work around this. It > probably isn't too hard as I look at my object model, but I was going to > relegate this to "Optimize Last." This is not necessarily an optimization but rather a removal of unnecessary genericity. Let me explain: in java when you use a collection, you simply say all objects in it are of type Object or subtypes thereof. This may be well but usually you only mean to put objects of type SomeBaseType or subtypes of it, into the collection. So why not using the ability of a compiler to check that you don't put objects of other types in it by accident (this is called generic types and will be available in Java 1.5 btw). In JDO it is similar to Java (well actually it is the same): it is usually better though less convenient to have associations as un-generic as possible. Though here it may be more of performance reasons than static type-checking. Tom --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
