Hi Thomas,

  OJB decides internally whether to use INSERT or UPDATE by calling
materializeObject (as I understand it). materializeObject is only used
(AFAIK) to check if the primary key exists. Since materializeObject doesn't
guarantee the object's existance (since two INSERTs can occur simultaneously
in two different transcations), using the cache as discriminator before
calling materializeObject can save a DB SELECT call (which BTW doesn't fetch
only the primary key but also the entire basic object). Assuming that
there's a cache hit for every object fetched previously in the transaction,
updating an object results in 2 SQL calls instead of 3.

Tal


"Mahler Thomas" <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>..
.
> Hi Tal,
> 
> OJB's store method does not differentiate between INSERT and UPDATE. Thus
> OJB must decide internally which method is to be used.
> 
> If you know in advance if you have to use an INSERT (or an UPDATE) you
cant
> give OJB a hint.
> just use PB.store(instace, ObjectModification)
> 
> The objectModification tells the broker if insert or update is needed.
> 
> cheers,
> Thomas
> 
> > [Standalone OJB 0.9.7 with default cache, Oracle 8i]
> > 
> > Hi,
> > 
> > Using the singlevm.PersistenceBroker, I've created a (very) 
> > simple test. I
> > query for an object, modify and then store it. When looking 
> > at the SQL log I
> > notice that two SELECT statements are being called (one when 
> > querying and
> > one when storing).
> > From taking a short look at the code I understand that the 
> > 2nd SELECT is
> > done in store() (by calling materializeObject) to determine 
> > between INSERT
> > and UPDATE statements. Isn't it the cache's property? As I 
> > understand it,
> > this means that a redundant SELECT is being done for each object.
> > 
> > I'd appreciate any help.
> > 
> > Thanks,
> > Tal
> > 
> > --
> > To unsubscribe, e-mail:   
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: 
> > <mailto:[EMAIL PROTECTED]>
> > 
> > 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to