Entity gets duplicating in Table when mutiple clients requests


EJB programming & troubleshooting: Entity gets duplicating in Table when mutiple clients requests

  1. Dear All, need help, I am finding solution to following scenario since last 3-4 days but not got any comfortable solution, - when multiple clients request the Account Entity Bean in EJB 3.0 then duplication happens in database table.... So tried with synchronization at Session facade - not worked good , with Singleton class also played lot creating sparate class for calling Entity bean ,but not. May this is problem of EJB 3.0 for Versioning and data Stomping ?.... Please suggest for solution, Thanks, Sandeep Kutwal, India
  2. What to you think should happen when multiplie clients call your account bean? Is this a logical problem rather than a technical? Pessimistic approach: If it is just a matter of a race condition occuring under load, you should use a "synchronization" mechanism through your db, by using "select for update" that will lock a common tuple with a read lock. With ejb3 use the class "LockMode" for this purpose. That way the transactions will be serialized for this exact concurrency case. Optimistic approach: Use versioning, and do a automatic retry x noof times at concurrency failures. Othewise, it is usually just a matter of coding logic. You should defenitly not synchronize session beans, etc. That violates the ejb-spec and just is not a good idea! /N
  3. Sorry, it should say "write lock", not "read lock".