Armin, thanks for your reply.

We have transactions that span multiple web requests (pages) and we use
the PK values to identify objects that have been persisted on the
various pages (in order to re-display the contents of the objects if the
user goes back to one of those pages). 

There are definitely many other ways we could have solved this problem
but re-using the IDs created by the makePersist method seemed the most
straightforward (since OJB makes sure that all of the IDs are unique).

Thanks for your suggestion of using the SequenceManager.

-Dirk


-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 10, 2006 7:02 AM
To: OJB Users List
Subject: Re: OJB 1.0.4 and ODMG Database.makePersistent

Hi Dirk,

Kessler, Dirk wrote:
> There appears to be a change in behavior in the
Database.makePersistent
> method. In OJB 1.0RC7 the Database.makePersistent class would update
the
> primary key field of the object being persisted (autoincrement) even
> before the transaction was committed (I.E. right after the
> makePersistent call). It appears that in OJB 1.0.4 the primary key
value
> does not get updated until the transaction is committed.
> 

yep, this change was needed to harmonize OJB behavior with 
SequenceManager based on database identity columns. In this case it's 
not possible to set the PK values when the object is stored 
(#makePersistent call), only after the object is written to DB.
Only this way OJB will show the same behavior for all DB/PK-generation.

>  
> 
> Is there any way to have makePersistent set the primary key value (it
> can't be a transient value, it has to be the balue eventually stored
in
> the database)?
> 

It would be easy to implement a method which lookup the SequenceManager 
obtain the next PK value and set this value in your object - but this 
will cause some overhead.
Why do you need the "PK assign before store" functionality?

regards,
Armin

---------------------------------------------------------------------
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