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 Emmanuel Dupont <em...@jwaretechnologies.com> on 2003/06/19 12:00:21 UTC

RE : RE : Updating Objects

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. 

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 ?



-----Message d'origine-----
De : thma32@web.de [mailto:thma32@web.de] 
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:thomas.mahler@itellium.com] 
> 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: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


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


RE : RE : RE : RE : Updating Objects

Posted by Emmanuel Dupont <em...@jwaretechnologies.com>.
After a while, I agree.

Thanks again for your response Thomas  !!



-----Message d'origine-----
De : thma32@web.de [mailto:thma32@web.de] 
Envoyé : jeudi 19 juin 2003 14:50
À : OJB Users List
Objet : Re: RE : RE : RE : Updating Objects

Hi Emmanuel,

IMO it's not good to mix the PB and ODMG API in this way.
It's really difficult to read.

And the locking really doesn't help you in this case, as you change the 
Identity of the object in the next line:
objectUpdated.setId_pk(aclModel.getId());

cheers,
thomas

Emmanuel Dupont wrote:
> 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 : thma32@web.de [mailto:thma32@web.de] 
> 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 : thma32@web.de [mailto:thma32@web.de] 
>>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:thomas.mahler@itellium.com] 
>>>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: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


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


Re: RE : RE : RE : Updating Objects

Posted by Thomas Mahler <th...@web.de>.
Hi Emmanuel,

IMO it's not good to mix the PB and ODMG API in this way.
It's really difficult to read.

And the locking really doesn't help you in this case, as you change the 
Identity of the object in the next line:
objectUpdated.setId_pk(aclModel.getId());

cheers,
thomas

Emmanuel Dupont wrote:
> 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 : thma32@web.de [mailto:thma32@web.de] 
> 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 : thma32@web.de [mailto:thma32@web.de] 
>>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:thomas.mahler@itellium.com] 
>>>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: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


RE : RE : RE : Updating Objects

Posted by Emmanuel Dupont <em...@jwaretechnologies.com>.
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 : thma32@web.de [mailto:thma32@web.de] 
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 : thma32@web.de [mailto:thma32@web.de] 
> 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:thomas.mahler@itellium.com] 
>>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: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


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


Re: RE : RE : Updating Objects

Posted by Thomas Mahler <th...@web.de>.
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 : thma32@web.de [mailto:thma32@web.de] 
> 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:thomas.mahler@itellium.com] 
>>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: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>