ojb 1.0.3 and pb api. To start with I wasnt setting the back reference (as when i wrote the code it didnt have a back-reference).
I then added the back reference, which caused the problem. Setting the back reference solves it. I can understand why it does it - update activity generates activity id, then it sets it in attachment, and saves attachment, causing it to check the activity reference, and then change id back to null (0). It just seemed a bit odd to start with. Daniel. > -----Original Message----- > From: Armin Waibel [mailto:[EMAIL PROTECTED] > Sent: 07 November 2005 09:45 > To: OJB Users List > Subject: Re: PB linking problem > > > Hi Daniel, > > which version of OJB and which API (PB-api or ODMG) do you use? > Do you set the back-reference in attachment when adding to actitvity? > ... > activity.addAttachment(attachment); > attachment.setActivity(activity); > ... > > regards, > Armin > > Daniel Perry 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? > > > > Daniel. > > > > > > --------------------------------------------------------------------- > > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
