Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes EJB and other Java EE Technologies and the fly likes EJB calling syncronized method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB calling syncronized method" Watch "EJB calling syncronized method" New topic

EJB calling syncronized method

Mike Nason

Joined: Apr 19, 2006
Posts: 20

Does anybody knows is it allowed to call syncronized method from EjbBean(sync method in other object, not in ejb)?

My problem is the following: the database table has rows.
An operator uses GUI to get rows from db to browse, then can modify any single row(also do some other things).

Many operators are working with GUI, so 2 operators can browse the same rows, but one row can be modified by one operator only.
I use EJB to get & modify rows. My web module calls EJB to perform fetching and modification.

The problem is when EJB instance(operator1) is modifing some DB record, the other EJB instance(operator2) overwrite the changes.

The solution can be to place modification logic to syncronized method, so this method will be called from multiple EJB instances.
Is it allowed?
Any other ideas?

I use EJB 2.1.


Wanna code??
Prabaharan Gopalan
Ranch Hand

Joined: Oct 16, 2009
Posts: 66 - does this answer your question?

Googling doesn't make you a genius. But not Googling makes you dumber.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: EJB calling syncronized method