读书人

Spring测试中Hiberante session缓存有

发布时间: 2012-11-04 10:42:42 作者: rapoo

Spring测试中Hiberante session缓存问题
测试很关键..没有测试的代码是遗留代码...

Spring给测试提供了好多方便之处.

protected void flushSession();{ SessionFactory sessionFactory = (SessionFactory)applicationContext.getBean("sessionFactory"); sessionFactory.getCurrentSession().flush();sessionFactory.getCurrentSession().clear(); }

在测试方法中,如果要查询已查询过的数据,可以在查询之前用调用下这个方法..

读书人网 >软件架构设计

热点推荐