Richard, You might try setting up the reference as a proxy and then create a proxy object and set the identity on it. This way your object model would not be out of synch with your database. I'm not sure if OJB is going to try to materialize the proxy on store though.
Maybe one of the developers can comment further on this. I.E. How concrete is the proxy implementation? Does a factory exist to create a proxy object when given an Identity object? Does OJB try to materialize a proxy on store? Wally -----Original Message----- From: Richard Schuller [mailto:[EMAIL PROTECTED] Sent: Monday, February 09, 2004 1:42 PM To: OJB Users List Cc: Gelhar, Wallace Joseph Subject: RE: This looks like a bug in store() Thanks Gelhar, While that works it results into an unnecessary database call. Is there a way to bypass this behaviour? Richard --- "Gelhar, Wallace Joseph" <[EMAIL PROTECTED]> wrote: > Hi Richard, > > This is not a bug, but rather behavior by design. > > OJB is an object level mapping layer. Therefore, OJB > is using the value > of the reference object you set (null!) and updating > the FK (i.e. > clearing the field). If you first set the FK and > want to resolve the > object, you may call pb.retrieveReference("referenceAttribute"); to > load the object before storing. > > Hope this helps. > > Wally > > -----Original Message----- > From: Richard Schuller [mailto:[EMAIL PROTECTED] > Sent: Monday, February 09, 2004 1:20 PM > To: [EMAIL PROTECTED] > Subject: This looks like a bug in store() > > > I have a class A representing table TA defined as > follows: > > class A { > .... > private Long sourceId; > private Long targetId; > ... > TCorporation source; > TCorporation target; > } > > If I set the sourceId to new Long(1234) and > source=null the INSERT statement generated blanks > out > the source id. > > Anybody else ran into this? > > Richard > > > > __________________________________ > Do you Yahoo!? > Yahoo! Finance: Get your refund fast by filing > online. > http://taxes.yahoo.com/filing.html > > --------------------------------------------------------------------- > 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] > __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
