dcsimg
EJB transaction logic with locking
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   saba_sundke
Posted On:   Monday, July 2, 2001 08:24 PM

Hi, I have 2 stateless container managed transaction beans called OrderSLB and ContractSLB and one CMP bean OrderEB wrapping around an order table. The orderslb has a method called updateOrder() defined with a Required attribute. This method does the update on the order row be looking up the OrderEB bean by findByPrimaryKey() (...besides some other operation ...) The second bean contract bean has a method called executeContract() been defined with Required attribute. This method does 3 things 1) Check for business validity. 2)updates a status field in the order table so looks up the orderEB to do the job 3) Inserts a reco   More>>

Hi,


I have 2 stateless container managed transaction beans called OrderSLB and ContractSLB and one CMP bean
OrderEB wrapping around an order table.



The orderslb has a method called updateOrder() defined with a Required attribute. This method does the
update on the order row be looking up the OrderEB bean by findByPrimaryKey() (...besides some other
operation ...)




The second bean contract bean has a method called executeContract() been defined with Required attribute.
This method does 3 things

1) Check for business validity.

2)updates a status field in the order table so looks up the orderEB to do the job

3) Inserts a record in the Contract table.

The ordereb has ben set with a serializable transcation isolation



When 2 user do a simultaneous where one does an updateOrder() and one and executeContract() I want only
one user to succeed and i should be able to give an error message to the other user.

Now i get a number of outputs when i try to do the operations simultaneously. One of them is : the updateorders()
happenes first, then the update of status on the executeContract(). (note this happens between the validity
check and the change of status...) Businesswise this is a bad situation. How do i prevent this ? How
do i implement locking so that i know when i start the trasaction for exceuteContract() the order will
not be updated



Im using Weblogic 5.1 and Oracle 8.1.6


Saba

   <<Less
About | Sitemap | Contact