3 Replies Latest reply on Oct 16, 2003 11:40 PM by nraghuram

    How to configure jboss for optimistic locking?

    equine

      Hi,
      I am using jboss 3.2.1 with bundled tomcat 4.1.24.
      If anyone can help me out to configure jboss for optimistic locking.

      All the EJB's in my application are CMP. The transactions are long, thus deadlock situation is occuring when two users are trying to access a single bean and going for timeout.

      If any other solution is available that will be great.

      Thansks in Advance

        • 1. Re: How to configure jboss for optimistic locking?
          nraghuram

          You need to modify the container configuration in jboss.xml and also make changes at the entity level in jbosscmp-jdbc.xml
          I am using version based locking (there are other options also like timestamp and modified fields) .

          I had to add the foll to each entity which required optimistic locking in jbosscmp-jdbc.xml
          <optimistic-locking>
          <version-column/>
          <field-name>versionNo</field-name>
          <column-name>VERSION_NO</column-name>
          <jdbc-type>BIGINT</jdbc-type>
          <sql-type>NUMBER</sql-type>
          </optimistic-locking>

          In jboss.xml the foll changes to the container configuration
          <locking-policy>org.jboss.ejb.plugins.lock.JDBCOptimisticLock</locking-policy>

          hth
          raghu

          • 2. Re: How to configure jboss for optimistic locking?
            equine

            Do I need to create any field on database table?

            • 3. Re: How to configure jboss for optimistic locking?
              nraghuram

              yes. in my case i created the VERSION_NO field . but if u are using locking strategy based on modified fields then u dont. for version locking and timestamp based locking u will need the field
              raghu