今天在学习使用hibernate4,在调用sessionFactory.getCurrentSession().save(entity);进行保存操作时,方法执行成功,但是数据没有插入到数据库,控制台也不报错,在网上各种查找解决方法之后找到思路,这个问题是跟flushMode的属性有关,为什么会这样呢?因为我在dispatcher-servlet.xml和spring-hibernate.xml中都是配置的
<context:component-scan base-package="com.test">
后来把dispatcher-servlet.xml中改为
<context:component-scan base-package="com.orange">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
</context:component-scan>
spring-hibernate.xml中改为
<context:component-scan base-package="com.orange">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-