File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Websphere and the fly likes Question to Kyle Brown Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Question to Kyle Brown" Watch "Question to Kyle Brown" New topic

Question to Kyle Brown

mustang india
Ranch Hand

Joined: Feb 05, 2002
Posts: 60
Hi kyle,
My question might be a wrong one but I am just asking to make a clarification. I request apologies if the question is an absurd one.
I was going trhu one of the chapters of "Enterprise Java Programming with IBM WebSphere " which discuss about
"The session facade and data bean solution"
In this solution a servlet requests a session bean which inturn gets the data of an entity bean into a data bean(an oridnary java bean) and returns the data bean to the servlet. The idea is to reduce the network calls to the EJB and to have a local representation of data. But if the underlying data in DB gets updated or modified, the data bean becomes stale. If u r getting the info from the entity bean then there is a fair chance of getting the most recent data as it gets updated by activate/passivate actions. How far am I correct and how to address this problem ?
Simon Song
Ranch Hand

Joined: Feb 01, 2002
Posts: 217
Your concern is valid, that's why you may want to adopt Optimistic locking to validate your data in memory is consistent with the one in DB.
Generally, each invocation to Entity Bean will invovle ejbLoad() first. And in WAS, you can use Pessimistic locking for this operation, which in turn will use select ... for update to locking the underlying record, so later on your biz operation in this transaction has the right data in hand.
But usually, the lock should not expand user's thinking time. So you won't lock the record and wait till user operates. You can use version attribute in your object to stamp it with some version, and if other people change the record in DB, the version will mismatch and transaction will not go through.
Both transaction styles are supported from WAS 4.0.2, so...

Simon Song
Certified Entperise Developer of Websphere
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Simon's posting is correct. The idea is that the Data access bean (or Value object) does not survive user think time. It only lasts as long as it takes to build and display the web page. Thus it is possible that the data could become stale in the short amount of time (milliseconds) between obtaining the data from the session bean and building the web page in the JSP.
If your EJB values change faster than the time it takes to build a web page, you're in bigger trouble than we can help you with

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
I agree. Here's the link:
subject: Question to Kyle Brown
It's not a secret anymore!