If you've got an object with a many-key to another object, with a many-key to another object...


What happens when I want to add a new (from the example) UserSubscription object, with a UserSubscriptionService in it? How do the many-key fields get updated?

1) Is JDO going to write them out in the order of their dependencies, and update the many-key value itself? (which doesn't appear to be working)

or

2) Should I be having setId() automatically update the matching ID in dependent fields?

I have it working for cases where I'm adding an object to another's collection list by setting it manually during the addWibble() call; but this situation arises when the thing with the addWibble() call doesn't yet have an ID of its own. Will JDO call setId() in the right order?

Such as:

<class name="com.wow.framework.dao.User" identity="id" access="shared" key-generator="identity">
[...]
<field name="subscriptions" type="com.wow.framework.dao.UserSubscription" collection="arraylist" get-method="getSubscriptions" set-method="addSubscription">
<sql many-key="user_id"/>
</field>
</class>
<class name="com.wow.framework.dao.UserSubscription" identity="id" access="shared" key-generator="identity" depends="com.wow.framework.dao.User">
<field name="id" type="integer">
<sql name="id"/>
</field>
<field name="userId" type="integer">
<sql name="user_id"/>
</field>
[...]
<field name="services" type="com.wow.framework.dao.UserSubscriptionService" collection="arraylist" get-method="getServices" set-method="addService">
<sql many-key="user_subscription_id"/>
</field>
</class>
<class name="com.wow.framework.dao.UserSubscriptionService" identity="id" access="shared" key-generator="identity" depends="com.wow.framework.dao.UserSubscription">
<field name="id" type="integer">
<sql name="id"/>
</field>
<field name="userSubscriptionId" type="integer">
<sql name="user_subscription_id"/>
</field>
</class>




----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev

Reply via email to