publicvoidexecuteTask() { logger.debug("get the Gadget class Bean,DagetDao={}", dao); //添加节点 dao.addNodeIfAbsent("Gadget"); //查询节点 boolean result = dao.nodeExists("Gadget"); logger.debug("add Node success or not ,{}",result); try{ //删除节点 dao.deleteNodebyName("Gadget");
} catch (Exception e) { e.printStackTrace(); } //再次查询节点 logger.debug("Node exist or not ,{}",dao.nodeExists("Gadget")); }
上面测试代码总共4次操作jackrabbit,应该使用4个session
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
2015-08-2020:24:42 [main] DEBUG org.springmodules.jcr.JcrSessionFactory -no session holder provider manager set; using the default one 2015-08-2020:24:42 [thread-0] DEBUG com.huawei.jackrabbit.test.service.GadgetnoTransactionService -get the Gadget class Bean,DagetDao=com.huawei.jackrabbit.test.DAO.GadgetDao@1e22c75 2015-08-2020:24:42 [thread-0] DEBUG org.springmodules.jcr.SessionFactoryUtils -Opening JCR Session 2015-08-2020:24:42 [thread-0] DEBUG com.huawei.jackrabbit.test.DAO.GadgetDao -Starting from root node. node=node / 2015-08-2020:24:43 [thread-0] INFO com.huawei.jackrabbit.test.DAO.GadgetDao -Saved node. node=node /Gadget 2015-08-2020:24:43 [thread-0] DEBUG org.springmodules.jcr.SessionFactoryUtils -Closing JCR Session 2015-08-2020:24:43 [thread-0] DEBUG org.springmodules.jcr.SessionFactoryUtils -Opening JCR Session 2015-08-2020:24:43 [thread-0] DEBUG com.huawei.jackrabbit.test.DAO.GadgetDao -Starting from root node. node=node / 2015-08-2020:24:43 [thread-0] DEBUG org.springmodules.jcr.SessionFactoryUtils -Closing JCR Session 2015-08-2020:24:43 [thread-0] DEBUG com.huawei.jackrabbit.test.service.GadgetnoTransactionService -add Node success or not ,true 2015-08-2020:24:43 [thread-0] DEBUG org.springmodules.jcr.SessionFactoryUtils -Opening JCR Session 2015-08-2020:24:43 [thread-0] DEBUG com.huawei.jackrabbit.test.DAO.GadgetDao -delete the node name =Gadget 2015-08-2020:24:43 [thread-0] DEBUG com.huawei.jackrabbit.test.DAO.GadgetDao -the node exist or not ,false 2015-08-2020:24:43 [thread-0] DEBUG org.springmodules.jcr.SessionFactoryUtils -Closing JCR Session 2015-08-2020:24:43 [thread-0] DEBUG org.springmodules.jcr.SessionFactoryUtils -Opening JCR Session 2015-08-2020:24:43 [thread-0] DEBUG com.huawei.jackrabbit.test.DAO.GadgetDao -Starting from root node. node=node / 2015-08-2020:24:43 [thread-0] DEBUG org.springmodules.jcr.SessionFactoryUtils -Closing JCR Session 2015-08-2020:24:43 [thread-0] DEBUG com.huawei.jackrabbit.test.service.GadgetnoTransactionService -Node exist or not ,false
encountered an error.org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252) at java.util.concurrent.FutureTask.get(FutureTask.java:111)