db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thoralf Rickert" <thoralf.rick...@cadooz.de>
Subject AW: Best practice for entity update.
Date Fri, 09 Feb 2007 12:10:02 GMT
Hi!

If it isn't possible to use a transaction connection you can use a timestamp column to verify
if the row is changed in the database. Before saving the instance you can read the timestamp
column from the DB and compare it with the timestamp that is set in your instance (this should
be done in a "short transaction" during save()).

bye
Thoralf

> -----Urspr√ľngliche Nachricht-----
> Von: Christopher Thill [mailto:cthill69@yahoo.com] 
> Gesendet: Freitag, 9. Februar 2007 12:46
> An: Apache Torque Users List
> Betreff: Best practice for entity update.
> 
> 
> I wanted to ask a question about the best way to
> prevent users overwriting each others changes when
> updating the database.
> 
> If you use the simplest way
>   IntakeTool intake = (IntakeTool)
> context.get(ConstSpr.INTAKE_STRING);
>   Group group =
> intake.get(ConstSpr.INTAKE_SPRSA_CONTRACT,IntakeTool.DEFAULT_KEY);
>   SprsaRsaContract sprsa = new SprsaRsaContract();
> 
>   group.setProperties( sprsa );
>   sprsa.save();
> 
> You can over right another users changes to the
> database.
> 
> I have decided to stuff the torque object used to
> build the form into the users temporary storage and
> then when the user submits the form I retreive it and
> do something like :
> 
>    Criteria whereCriteria =
> SpscmSalesCompanyPeer.buildCriteria(this);
>    Criteria updateCriteria =
> SpscmSalesCompanyPeer.buildCriteria(newValues);
> 
>    SpscmSalesCompanyPeer.doUpdate(whereCriteria,
> updateCriteria);
> 
> Then check to see how many rows were updated.
> 
> Any suggestions for this would be appreciated.
> 
> Thanks,
> Chris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 


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


Mime
View raw message