Jean:
    when we do pessimistic and optimistic concurrency ? i would say for read
only operation container can do optimistic and for mutators it should do
pessimistic . Can we enforce the container to do this kind of things. i am
new to EJB and trying to understand what the container does when we do
transactions .

Thanx : Asha

-----Original Message-----
From: Jean-Baptiste Nizet [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 17, 2000 1:27 AM
To: [EMAIL PROTECTED]
Subject: Re: What is pessimistic and Optimistic concurrency?


Suppose you have an entity bean representing an account. This account is
owned
by several people, each of them being allowed to perform operations on the
account.
Now suppose that two of these people start a transaction and try to access
the
bean.
If pessimistic concurrency is used, then the first one who uses the account
bean
will obtain a lock on this bean. The other one will have to wait until the
first
transaction ends before to be able to perform an operation on the bean. That
way, you'll be sure that the information that you get in the bean is
accurate
information, and that you'll read the latest state of the bean. On the other
hand, if the two persons just want to have the balance of the account
(read-only
operation) and if the first transaction is long, then the second person will
have to wait for nothing.
Now if optimistic concurrency is used, then the two persons will be able to
access the bean simultaneously. There will be no lock on the bean itself. If
the
operations they perform are read-only, no problem. Now if the operations
they
perform update the state of the bean, it can lead to problems. For example,
if
the two persons increment read the initial balance (5000) and then increment
it
(+1000), instead of having a final balance of 7000, the account will have a
final balance of 6000. Now depending on the configuration of the database
transaction isolation level, and on other configuration options the
container
might provide you, the second transaction could fail and rollback, and you
might
have to retry the transaction.

Hope it was clear.

JB.

P.S. : to the maintainer of this mailing list : is it normal that I don't
receive the messages I post. It's rather annoying to have incomplete threads
and
not to be able to easily find the reactions to your posts.

Asha Balasubramanyan wrote:

> Hi:
>
>   In this forum in lot of disccusions , i heard Pessimistic/optimistic
> concurrency , can anyone tell me what this means?
>
> Thanks
> Asha
>
>
===========================================================================
> 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".

--
Jean-Baptiste Nizet
[EMAIL PROTECTED]

R&D Engineer, S1 Belgium
Excelsiorlaan 87
B-1930 Zaventem
+32 2 714 45 42

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