db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: [ODMG] Modifying object states of object evelopes inside a transaction
Date Tue, 12 Jul 2005 16:30:28 GMT
Hi Bart,

Bart Molenkamp wrote:
> Hi,
> 
> I'm using OJB 1.0.3, and I'm still having problems when storing large
> object graphs (which I already had). 

Could you describe more detailed the problems (sorry I can't remember
your last post)?


> I solved this problem, by listening
> to the PBStateListener.afterBegin() method. In this method, I use the
> metadata from the OJB metadata manager to clone myself a new object,
> which has no relationships to any other objects. This object is then
> stored using the persistence broker. This is done for all objects that
> are made persistent. After this, all objects are stored again, but now
> including all relationships etc. This works pretty good for me.
>

What's the advantage of storing a "flat" object copy before storing the
real object?

> But now I'm having a little problem, when locking a persistent object
> that has a reference to a new object. The ODMG layer marks this object
> as StateNewDirty. I also insert the new object in
> PBStateListener.afterBegin(). So I get an error, as OJB tries to insert
> the object twice.
> 
> Is there anyway that I can set the state to StateOldClean or something,
> to let OJB know that it shouldn't care about that object anymore?
> Letting OJB do the insert fails (the graph problem).

there is no "official" way to change object state in OJB's odmg
implementation. You need access to the ObjectEnvelopeTable instance used 
by TransactionImpl (field is protected, so you have to use reflection). 
In this case you can lookup the ObjectEnvelope instance for the 
persistent object and change the state of the object.

regards,
Armin



> 
> Thanks,
> Bart.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message