Hi,
we need to implement the functionality that a java client can
lock an entity in the database while a user is editing that
entity. We have implemented this in our existing (non-EJB) application
server, and now need to figure out how to do this with EJB.
After reading up on EJB, it seems the most obvious way to
do this is to use bean-managed transactions and have a session bean
method "lockEntity", which creates a new transaction and calls
"SELECT FOR UPDATE NOWAIT".
When the user saves his changes, the data is passed to another
session bean or entity bean that uses the initial transaction
context to save the changes. The client then commits and ends the
transaction.
(The thread that started the transaction in the GUI
may not be the same thread that issues the save and commit - is
that a problem?)
I know that this is not the recommended approach due to scalability,
but we have done it this way in the past and it has worked for
us. Did the above make sense or is there a better way to accomplish
this?
One problem here is how do we detect that a client disconnected, such
that we can cleanup the transaction? We used to have the client
send keep-alives, and when a timeout was detected, the database
connection was returned to a pool and rollback() was called.
But, I can't see how to do cleanup using EJB. Could someone elaborate?
Besides using a database connection, what other resources or negative
effects does this pessimistic locking strategy have? I found plenty
of references that say "don't use client demarcated transactions and
don't use pessimistic locking", but no real explanation was given.
Thank's in advance
Andrej
__________________________________________________
FREE voicemail, email, and fax...all in one place.
Sign Up Now! http://www.onebox.com
===========================================================================
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".