Thomas Dudziak wrote:

On Fri, 6 Feb 2004, Gus Heck wrote:


How do I get around this? or am I forced to put in useless, backreference?



The reference from the element object to the object with the collection is
not at all useless. It is how OJB actually implements the 1:n association
(it stores the primarykey of the object with the collection).


well I meant useless from a business logic perspective. I supose it is not useless in the sense that it does make OJB work. It would be nicer however if this were not required. Does this mean an object can only be held in a persistant collection if it has a field for that collection, and the programmer needs to ensure that there is a field for any collection the object might belong to?

So basically you put in a field into the element type of the same type as
the primarykey.


I assume you mean primary key of the object with the collection?

There is a way to avoid this, however, by using an indirection table (as a
1:n association is a m:n association with an implicit constraint). Here
you have the foreignkeys in a separate table referencing the primarykeys
of the two ends of the association.


Interesting. is there an example of this somewhere? How would this work with JDO? Can this table be generated as needed somehow? That would be ideal. I would like my objects to simply use their collections as normal java collections, otherwise, I have to go back and carefully analyze my object model to find all the collections that each object might wind up in.

BTW, when you use a collection type (as opposed to an array), you have to
specify the element type, as well (using element-class-ref).



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)

-Gus



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



Reply via email to