I'm using 1.2 JDO and I'm pretty sure I already know the answer to this 
question, but I thought I'd ask just in case I overlooked something.  Is it 
possible to create a one-to-many JDO mapping where the column used on the many 
object doesn't refer to the ID of the one, but rather another column on the one 
object?

For example if object model looked something like this:

ManyObject
-id (object id/pk)
-name
-category

OneObject
-id (object id/pk)
-category
-manyObjects (collection of 'ManyObject's where OneObject.category == 
ManyObject.category)

So the mapping would look something like:
<field name="manyObjects" type="ManyObject" collection="vector">
  <sql many-key="category"/>
</field>

I believe the only way to do this currently would be to change "ManyObject" to 
add a fk field that held the value of OneObject.id.
<field name="manyObjects" type="ManyObject" collection="vector">
  <sql many-key="one_object_id"/>
</field>

Thanks,
Jon

Thanks,
Jon

Reply via email to