Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

EJB transaction logic with locking

Posted on 2001-06-27
6
Medium Priority
?
190 Views
Last Modified: 2013-11-24
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 repeatable read 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.0.6

Saba

0
Comment
Question by:sabaus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 6230702
Hacky answer, but couldn't you set a

  public static boolean flag = false ;

variable in your ContractSLB, and then set this to true when someone does an executeContract().

Then check this variable:

  if( ContractSLB.flag )
    return someError;

in your update order method...

Hmmm...might work...must be a better way of doing though...

Good Luck,

Tim.
0
 

Author Comment

by:sabaus
ID: 6234108
Its crazy ... im talking here about stateless beans how can i be gauranteed that i will be given the same bean when i check in the updateorder() method. Moreover im talking here about millions of orders being exceuted... its impossible here to track some order and flag relationship

Saba
0
 
LVL 35

Expert Comment

by:TimYates
ID: 6234798
I'm talking about a static variable...

Also, I thought EntityBeans (which I guess you are using for the db Access) implemented locking, so you won;t get to events occuring at the same time?  I thought this was the whole point...  Basically Transaction based locking...

maybe I am crazy tho
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:sabaus
ID: 6236675
Its crazy doing it this way. Why should I prevent someone from updating his order when someone else's order being executed? There has to be a way of being more specfic to an order so that we can achieve an order based locking.
0
 
LVL 5

Expert Comment

by:vemul
ID: 7616537
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- To be PAQ'ed and points refunded
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 7639838
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question