I have code that (within a  single transaction) removes a node and then puts a 
new value into the cache that is a child of the removed node. After the 
transaction completes, the cache contains the new value AND the child nodes 
that should have been removed when the parent node was removed. If I execute 
the same code without a transaction, it works correctly, only the new value is 
present and all of the original children of the removed node are gone. The 
following code is a simple demonstration of the problem:


public class RemoveNodeTxProblem {
    public static void main(String[] args) throws Exception {
        CacheFactory<String, Object> factory = 
DefaultCacheFactory.getInstance();

        Cache<String, Object> cache = factory.createCache(new 
XmlConfigurationParser().parseFile(args[0]), false);
        cache.create();
        cache.start();

        Fqn rootFqn = Fqn.fromString("/a/b");
        cache.put(rootFqn, "c", true);

        TransactionManager txMgr = 
cache.getConfiguration().getRuntimeConfig().getTransactionManager();
        txMgr.begin();
        cache.removeNode(rootFqn);
        cache.put(rootFqn, "d", "Blah");
        txMgr.commit();

        System.out.println("c = " + cache.get(rootFqn, "c"));  // c = true when 
tx is used, null when tx is not used
        System.out.println("d = " + cache.get(rootFqn, "d"));

        cache.stop();
    }
}


Is this a bug? If not, is there a way to get the non-transactional behavior 
(deleted children don't come back after a new child is added) in a 
transactional way? I'm running JBoss Cache 2.0.0 GA and JOTM 2.0.9 as my 
transaction manager.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4132002#4132002

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4132002
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to