0 Replies Latest reply on Jan 16, 2006 3:48 AM by Arto Huusko

    Row locking?

    Arto Huusko Newbie

      I have a situation where I have multiple concurrent applications accessing the database. There are several legacy connections, and there is at least one JBoss, but there may be need for more JBoss instances in the future (not clustuered necessarily at all).

      The problem is, how do I synchronize access to database?

      By default, JBoss only locks the entities to synchronize access to the entities from separate transactions within the JBoss instance. In this situation, this is clearly not sufficient, because the other applications are not aware of JBoss and vice versa.

      The only way to do this is row level locking in the database. And indeed, the legacy applications do SELECT FOR UPDATE when they need to lock the data.

      I found out that JBoss supports this option also (row-locking CMP option), but this is implemented in very strange manner: it does not have anything to do with JBoss' locks. Instead, if row-locking is set to true, JBoss locks the entity in ejbLoad. Even though I would only call, for example, get* methods that are marked read-only, the row gets locked. That is: JBoss locks the row always, even if it does not lock the entity.

      Is there any way to go around this? Is the only way to add a business method that manually does the row lock (and the entity lock at the same time), at the request of the client software that accesses the entity?