2 Replies Latest reply on Jun 3, 2005 2:45 AM by Ruchi

    Transaction commit and replication

    Ruchi Newbie

      I have plugged in TreeCache in hibernate. To retrieve data from database i have coded -

      Session s = SESSION_FACTORY.openSession();
      Transaction txn = s.beginTransaction();
      TTkopOper tTkopOper = (TTkopOper) session.get(TTkopOper.class, operId);

      When i try to retrieve the data from database, the TreeCache.put() method is called on every call to Session.get(). The local cache is updated prior to commiting the transaction whereas cache replication takes place when transaction is commited.

      I have the following queries -
      1. How is TreeCache notified when a transaction commits. Is it notifed while transaction is commiting or after transaction has commited.
      2. Is TreeCache performing cache replication in the current transaction or is initiating a separate transaction of its own.
      3. Is cache replication performed parallel to database commit or after it is done.
      4. If database commit fails, is local cache and cache replication rolled back.

        • 1. Re: Transaction commit and replication
          Ben Wang Master

          1. before- and after-Completion

          2. in the current transaction

          3. after db, I think

          4. yes


          • 2. Re: Transaction commit and replication
            Ruchi Newbie

            I am using Websphere as the application server.

            2. I went through the hibernate source code and found that hibernate gets the user transaction via JNDI lookup. The transaction used is com.ibm.ws.Transaction.JTA.UserTransactionImpl .

            On the other hand, tree cache gets the transaction by calling transactionManager.getTransaction(). In tree cache logs, i see a line "removing local transaction com.ibm.ws.Transaction.JTA.TransactionImpl@1dc13f29#tid=1 and global transaction <>:1"

            As you can see these two transaction instances are different, this point is confusing me. I am unable to understand how treecache is notified on commit of hibernate transaction.

            4. There can be two scenarios -
            a) Cache Replication is performed parallel to database commit
            - In this scenario both the local and replicated cache has to be rolled back.
            b) Cache Replication is performed after database commit.
            - In this scenario only local cache has to be rolled back.

            What do u think how its been implemented a or b.