You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Kessler, Dirk" <di...@vontu.com> on 2006/01/06 02:51:36 UTC

OJB 1.0.4 and ODMG Database.makePersistent

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.

 

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

 

Thanks in advance,

 

-Dirk


Re: OJB 1.0.4 and ODMG Database.makePersistent

Posted by Armin Waibel <ar...@apache.org>.
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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org