spring事务准备

public class SpringTracelation {
    private ApplicationContext ctx=null;
    private BookShopDao bookShopDao=null;
    private BookShopService bookShopService=null;
    
    {
        ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
        bookShopDao=(BookShopDao) ctx.getBean("bookShopDao");
        bookShopService=(BookShopService) ctx.getBean("bookShopService");
    }
    @Test
    public void testBookShopService()
    {
        bookShopService.purchase("孔祥伟","1001");
    }
    
    public void testupdateUserAccount()
    {
        bookShopDao.updateUserAccount("孔祥伟",200);
    }
    
    public void testupdateBookStock()
    {
        bookShopDao.updateBookStock("1001");
    }
    
    public void testfindBookByIsbn()
    {
        System.out.println(bookShopDao.findBookByIsbn("1001"));
    }
}

你可能感兴趣的:(spring事务准备)