You need to use SERIALIZABLE isolation level. At this level, any information
read is guaranteed not to change until your transaction completes. So A's
transaction and B's transaction should have read "X" with serializable
isolation. It is up to the container/database to either have them run
consecutively (i.e. they were serialized), or end-up with B's transaction
terminating with a rollback due to a concurrency failure when the B goes to
commit.

Most implementations will result in locks being held appropriately to force
these components to be serialized in their execution, however there are a
few databases out there that will raise an error at B's commit time.
Therefore you might want to assume that there will be EJB Containers out
there that use the same algorithm to raise an error at commit time.

-----Original Message-----
From: [EMAIL PROTECTED]
Sent: Sunday, April 04, 1999 2:47 PM
To: [EMAIL PROTECTED]
Subject: Lost Updates and EJB


Hi all,

     I've been dusting off my old database book recently, and I've run into
an
interesting problem in transactions -- the Lost Update.  A lost update
occurs in
a scenario such as the following.  Assume two components A and B
concurrently
perform these operations:

1 Component A reads integer X from the database.  The database now contains
X =
0.
2 Component B reads integer X from the database.  The database now contains
X =
0.
3 Component A adds 10 to its copy of X, and persists it to the database.
The
database now contains X = 10.
4 Component B adds 10 to its copy of X, and persists it to the database.
The
database now contains X = 10.

Thus Component A's update has been lost.

Can someone reason to me which EJB transaction isolation level(s) explicitly
protect against Lost Updates, and how it protects against them?

Thanks
-Ed

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to