Spring测试中Hiberante session缓存问题
测试很关键..没有测试的代码是遗留代码...
Spring给测试提供了好多方便之处.
protected void flushSession();{ SessionFactory sessionFactory = (SessionFactory)applicationContext.getBean("sessionFactory"); sessionFactory.getCurrentSession().flush();sessionFactory.getCurrentSession().clear(); }
在测试方法中,如果要查询已查询过的数据,可以在查询之前用调用下这个方法..