So does this mean I can only have collections of a specific element type? What about collections that hold multiple types? Is it impossible to store them? I think that specification of element types is supposed to be optional for JDO. (allowing the implementation to optimize if it is specified)



In normal OJB (PB, ODMG) you specify 1:n associations (references), 1:n and m:n associations (colletions) between persistent classes (types that have a class descriptor). If you want a somewhat generic collection you have to find a common basetype of all possible element objects, which can be made persistent. Especially it needs to have primary keys. I don't know anything about JDO, but I guess it is the same there.

Tom




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.


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."

It looks like this typeless collection issue is something to think about for the final native JDO implementation. By the way does any1 know when work on the full native implementation is going to start? will it continue with the same classes and just work to replace the Sun dependancies, or will it be re-done from scratch?

-Gus


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to