ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Mills <developm...@peter.mills.to>
Subject Re: iBatis.Net - Optimistic concurrency control
Date Thu, 19 Apr 2007 17:01:04 GMT
What ways are everyone using to alert the application, when a 
concurrency check fails?  Are you checking the number of changed rows, 
after the update statement, and raising an error? 

Cheers,

Peter

Henrik Uffe Jensen wrote:

> Timestamp is a property on the object, so only one parameter (the 
> object) is passed
>  
> Employee.FirstName
> Employee.LastName
> Employee.TimeStamp
>  
> With Toms solution then there is a property called OriginalObject on 
> the object to update as far
> as I understand the solution, so again only one parameter
>  
> Employee.FirstName
> Employee.LastName
> Employee.OriginalObject.FirsName
> Employee.OriginalObject.LastName
>  
> regards
>  
> Henrik Uffe Jensen
> Corewit
>
>     ----- Original Message -----
>     *From:* Philippe Peuret <mailto:philippe.peuret@neoxia.com>
>     *To:* user-cs@ibatis.apache.org <mailto:user-cs@ibatis.apache.org>
>     *Sent:* Thursday, April 19, 2007 2:20 PM
>     *Subject:* RE : iBatis.Net - Optimistic concurrency control
>
>     I agree with your two solutions, but each time, there is two
>     diferrent parameter in the SQL query : the first parameter is the
>     Object to update (with all its data) and the second parameter is
>     the timestamp or a second object which contains data of the
>     original object. So, how do you do to pass two parameters to the
>     SQL query ?
>      
>     In the examples below, you can see only one parameter for the
>     current object "Employee" :
>      
>     <update id="UpdateEmployee" parameterClass="Employee">
>     UPDATE dbo.Employee
>     SET FirstName = #_firstNam#,
>            LastName = #_lastName#,
>            SSN = #_ssn#
>     WHERE EmployeId = #_employeeId#
>     AND [Timestamp] = #_timestamp#
>     </update>
>      
>     or
>      
>     <update id="UpdateEmployee" parameterClass="Employee">
>
>     UPDATE dbo.Employee
>
>     SET FirstName = #_firstName#
>
>                 , LastName = #_lastName#
>
>                 , SSN = #_ssn#
>
>     WHERE FirstName = #OriginalObject._firstName#
>
>                 AND LastName = #OriginalObject._lastName#
>
>                 AND SSN = #OriginalObject._ssn#
>
>     </update>
>
>      
>     ________________________________
>
>     De: Henrik Uffe Jensen [mailto:huj@corewit.com]
>     Date: mer. 18-avr.-07 20:43
>     À: user-cs@ibatis.apache.org <mailto:user-cs@ibatis.apache.org>
>     Objet : Re: iBatis.Net - Optimistic concurrency control
>
>
>     Another solution :
>      
>     Make timestamp column (SQL Server but probably similary data types
>     in other databases). This column is automatically updated by
>     sql server each time the row is changed, so you know that if the
>     timestamp column has changed since you pulled out the data then
>     there is a concurrency violation. So in your updates / deletes you
>     add [Timestamp] = #_timeStamp# to your where clause, for example
>      
>     UPDATE dbo.Employee
>     SET FirstName = #_firstNam#,
>            LastName = #_lastName#,
>            SSN = #_ssn#
>     WHERE EmployeId = #_employeeId#
>     AND [Timestamp] = #_timestamp#
>       
>     You can then use the rows affected returned by the Delete/Update
>     methods on the SqlMapper, and if it's 0 then at there is a concurrency
>     violation and you can throw an exception or whatever you do.
>      
>     regards
>      
>     Henrik Uffe Jensen
>
>     ----- Original Message -----
>     From: Nguyen, Tom <mailto:Tom.Nguyen@rels.info> 
>     To: user-cs@ibatis.apache.org <mailto:user-cs@ibatis.apache.org>
>     Sent: Wednesday, April 18, 2007 8:04 PM
>     Subject: RE: iBatis.Net - Optimistic concurrency control
>
>
>     Unless I'm behind on my knowledge, I don't believe that iBatis.Net
>     has automatic optimistic concurrency implementation.  You will
>     have to implement this yourself.
>
>
>
>     This is the pseudo of how I implemented mine:
>
>     BusinessBase<T> : IClonable
>
>     -Clone()
>
>     -OriginalObject AS T
>
>
>
>     Employee : BusinessBase<Employee>
>
>     -SSN
>
>     -FirstName
>
>     -LastName
>
>
>
>     1. Retrieve Employee
>     2. Clone Employee and store in OriginalObject
>     3. Employee is parameter class of Update Ibatis Mapping
>
>
>
>     UPDATE dbo.Employee
>
>     SET FirstName = #_firstName#
>
>                 , LastName = #_lastName#
>
>                 , SSN = #_ssn#
>
>     WHERE FirstName = #OriginalObject._firstName#
>
>                 AND LastName = #OriginalObject._lastName#
>
>                 AND SSN = #OriginalObject._ssn#
>
>
>
>
>
>     Unless you have build some kind of framework to do this, it is a
>     lot of manual, repetitive work.  Only do it when you really need to.
>
>
>
>     Regards,
>
>
>     Tom Nguyen
>     Sr. Developer
>     tom.nguyen@rels.info <mailto:tom.nguyen@rels.info>
>     <mailto:tom.nguyen@rels.info>
>
>
>
>
>     ________________________________
>
>
>     From: Philippe Peuret [mailto:philippe.peuret@neoxia.com]
>     Sent: Wednesday, April 18, 2007 7:20 AM
>     To: user-cs@ibatis.apache.org <mailto:user-cs@ibatis.apache.org>
>     Subject: TR: iBatis.Net - Optimistic concurrency control
>
>
>
>     Hello,
>
>
>
>     How to use the optimistic concurrency control when we update the
>     database with iBatis.Net ?
>
>     Because, when we use the <insert> or <update> elements, we can
>     only pass one parameter : the object to insert or to update. But
>     there is no other parameter to pass the data to the optimistic
>     concurrency control.
>
>
>
>     Thank you for your help.
>
>
>     ________________________________
>
>
>
>
>     This e-mail message and any files transmitted herewith, are
>     intended solely for the use of the individual(s) addressed and may
>     contain confidential, proprietary or privileged information.  If
>     you are not the addressee indicated in this message (or
>     responsible for delivery of this message to such person) you may
>     not review, use, disclose or distribute this message or any files
>     transmitted herewith.  If you receive this message in error,
>     please contact the sender by reply e-mail and delete this message
>     and all copies of it from your system.
>
>
>     ________________________________
>
>
>
>
>
>



Mime
View raw message