Last question Thomas, please,

Does that make sens to use the broker.store method inside an ODMG
transaction but not commit this ODMG transaction at the end to p^revent the
insert in database.

Like this :


tx = getNewTransaction();
broker = ((HasBroker) tx).getBroker();
                        
broker.beginTransaction();
objectUpdated = new Acl_acl_access_control_list();
tx.lock(objectUpdated, JwtTransaction.WRITE);                           

objectUpdated.setId_pk(aclModel.getId());       
objectUpdated.setName("myName");

broker.store(objectUpdated);
                        
broker.commitTransaction();

// Close the transaction
tx.abort();  // or tx.leave();

I use the ODMG API only to lock the "objectUpdated" during the update....

Instead I have to use ODMG completely without broker.store(), which is very
useful !

What do you think ?


-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Envoyé : jeudi 19 juin 2003 13:08
À : OJB Users List
Objet : Re: RE : RE : Updating Objects

Hi again,

Emmanuel Dupont wrote:
> I tested with: broker.store(instance) and with an ODMG query who look in
the
> database if the object is already present or not before inserting it.
> 
> It seems that (via P6Spy) the first choice (broker.store) has better
> performance.

OQL queries are slower than PB queries, because they have to be parsed 
first.

> 
> Why do you think Thomas that the second choice (query the existence or not
> for each object Updated in database via ODMG API before insert it) must be
> preferred ?

I don't think the second choice is better!

> 
> 
> 
> -----Message d'origine-----
> De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Envoyé : jeudi 19 juin 2003 11:28
> À : OJB Users List
> Objet : Re: RE : Updating Objects
> 
> Hi
> 
> Emmanuel Dupont wrote:
> 
>>Hi Thomas, Hi Eric
>>
>>I understand that OJB doesn't mind about this update method but what about
>>the database?
>>
>>If I create a new Object with the same Id (witch is the corresponding
>>primary key ID) and I persisting it, I have a "Double PRIMARY KEY
> 
> constraint
> 
>>ERROR" in my database.
> 
> 
> If you call broker.store(instance) OJB will check if the instance is 
> already present in the db. In Erics example it will perform an UPDATE, 
> not an INSERT!
> 
> 
>>So it is not possible to use this method ......No?
>>
>>
>>-----Message d'origine-----
>>De : Mahler Thomas [mailto:[EMAIL PROTECTED] 
>>Envoyé : mercredi 18 juin 2003 16:40
>>À : 'OJB Users List'
>>Objet : RE: Updating Objects
>>
>>Hi Eric,
>>
>>
>>
>>>Is it appropriate to update a persisted object by creating an 
>>>new object
>>>with same id as the persisted object and then persisting the 
>>>new object? 
>>
>>
>>I don't think this is "best practise". But there may be reasons to such
>>things...
>>At least from an OJB point of view I see no harm...
>>
>>cheers,
>>thomas
>>
>>
>>
>>>In
>>>case your curious, it does properly update the database. 
>>>
>>>Eric
>>>
>>>
>>>
>>>
>>>
>>>DISCLAIMER: The information contained in this e-mail is, 
>>>unless otherwise
>>>indicated, confidential and is intended solely for the use of 
>>>the named
>>>addressee. Access, copying or re-use of the e-mail or any information
>>>contained therein by any other person is not authorized. If 
>>>you are not the
>>>intended recipient please notify us immediately by returning 
>>>the e-mail to
>>>the originator.
>>>
>>
>>
>>
>>---------------------------------------------------------------------
>>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]
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> 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]
> 
> 


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