场景:程序A首先存一条数据,然后通过socket给B发送消息,让B取数据库里面去DB取数据
发现有时当B取数据时A还没有插入完成,应该在A类和方法上都要加上
@Transactional
spring中简单载入上下文:
public static void main(String[] args) {
ApplicationContext applicationContext = new FileSystemXmlApplicationContext("file:E:\\CommonContext.xml");
StatisDAO statisDAO = (StatisDAO) applicationContext.getBean("StatisDAO");
System.out.println(statisDAO.statisChanneltype("2011-04-02", "2011-08-02"));
System.out.println(statisDAO.statisExceptionfraud("2011-04-02", "2011-08-02"));
System.out.println(statisDAO.statisAccount("2011-04-02", "2011-08-02"));
}