3 Replies Latest reply on Nov 10, 2008 6:35 AM by manik

    SELECT FOR UPDATE semantics

    yonis

      Does JBoss Cache 3.x support SELECT FOR UPDATE semantics?

      I've seen a previous post on this subject but I'm not clear on what/if anything was implemented. The API does not seem to support it - no getForUpdate() method.


        • 1. Re: SELECT FOR UPDATE semantics
          mircea.markus

           

          Does JBoss Cache 3.x support SELECT FOR UPDATE semantics?

          Not at this moment. It can be emulated, though by using pessimistic locking with transactions. e.g. if you are using the repeatable_read isolation level, and read a node within a TX it will be locked and no other tx would be able to modify the node until this one finishes.
          This is not supported on MVCC though, which may be an drawback for you due to performance advantages MVCC brings.

          • 2. Re: SELECT FOR UPDATE semantics
            manik

            Actually, it is supported. :-)

            Just do this:

            // start transaction ...
            cache.getInvocationContext().getOptionOverrides().setForceWriteLock(true);
            Node n = cache.get("/a/b/c"); // this acquires a WRITE LOCK on this node
            ...
            ...
            // end transaction
            



            • 3. Re: SELECT FOR UPDATE semantics
              manik

              In fact, I am going to add this to the 3.x FAQs