hibernate调用sessionFactory.getCurrentSession().save(entity);数据无法插入到数据库

当使用Hibernate的SessionFactory.getCurrentSession().save(entity)尝试保存数据时,遇到无法插入数据库的问题。经检查,在重新运行项目后,数据成功插入。关键在于正确配置了web.xml文件。
摘要由CSDN通过智能技术生成
       今天在学习使用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-
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值