But surely it should update the activityId in the attachment object on
writing the activity (as activity has a collection of attachments, with
auto-update="object" ?

Daniel.

> -----Original Message-----
> From: Thomas Dudziak [mailto:[EMAIL PROTECTED]
> Sent: 04 November 2005 17:26
> To: OJB Users List
> Subject: Re: PB linking problem
>
>
> On 11/4/05, Daniel Perry <[EMAIL PROTECTED]> wrote:
> > Not sure if this is really an bug, or just a 'feature', but
> things dont get
> > linked under certain curcumstances.
> >
> > I have two objects: activity, and attachment.
> >
> > An activity has a collection of attachments.
> >
> >         /**
> >          * @ojb.collection
> element-class-ref="com.netcase.pol.bo.Attachment"
> >          *                 foreignkey="activityId"
> >          *
> > query-customizer="com.netcase.ojb.NotDeletedQueryCustomizer"
> >          *                 proxy="true" auto-retrieve="true"
> auto-update="object"
> >          */
> >         private List<Attachment> attachments;
> >
> > (attachment has: @ojb.field name="activityId" jdbc-type="INTEGER")
> >
> > The following works: (ie, activityId is set properly)
> > 1. persist an attachment.
> > 2. add it to the collection in activity.
> > 3. persist activity.
> >
> > However, if i add the following to attachment:
> >         /**
> >          * @ojb.reference foreignkey="activityId"
> >          */
> >         private Activity activity;
> >
> > then the above doesnt work.  activityId ends up as 0.  I guess i should
> > expect this as activity is null.  But, still, as activity is
> being persisted
> > last, shouldnt it be updated for that link?
>
> I think you have to set the activity field in your code initially
> (before writing). OJB will initialize the field only when reading
> objects from the database (and it doesn't do so in between storing the
> collection and the reference).
>
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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

Reply via email to