what happens when ejbStore() is called on locked row


EJB design: what happens when ejbStore() is called on locked row

  1. How does container respond to ejbStore() on a locked row by a stored procedure(complex calculation accessing multiple tables and self-joins) running on the database.

    Will the container throw ejb exception? or will it wait till the lock is released and then fire the store()
  2. In oracle, you can use SELECT...FOR UPDATE, which locks rows to be updated, provided the rows themselves are not already locked. If they are locked, then you must wait for the lock to be released. If you don't wish to wait, then you can use SELECT...FOR UPDATE NOWAIT, which throws an SQLException immediately if the rows attempted for update are already locked.

    If the stored procedure that is executing is locking rows for a shore period of time, then perhaps you may want to wait for the rows to be released. If the SP is a long transaction, then you may not want to wait.