hibernate调用sessionFactory.getCurrentSession().save(entity);数据无法插入到数据库
来源:互联网 发布:腾讯微信数据报告2017 编辑:程序博客网 时间:2024/06/08 15:29
今天在学习使用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-scan>
重新运行项目,数据能够insert到数据库中了。记得web.xml里配置
<filter><filter-name>OpenSessionInViewFilter</filter-name><filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class><init-param> <param-name>flushMode</param-name> <param-value>AUTO</param-value></init-param> </filter> <filter-mapping><filter-name>OpenSessionInViewFilter</filter-name><url-pattern>/*</url-pattern> </filter-mapping>我是个小菜鸟,只是把我的问题记录在这儿了,大家不喜勿喷。
0 0
- hibernate调用sessionFactory.getCurrentSession().save(entity);数据无法插入到数据库
- hibernate save没有保存数据到数据库
- hibernate save没有保存数据到数据库
- 关于HQL的save异常,无法正常将数据插入到数据库的问题
- hibernate 实行原生sql insert数据无法插入到数据库
- 【转】Hibernate SessionFactory().getCurrentSession()猫腻
- 新Hibernate SessionFactory().getCurrentSession()猫腻
- 新Hibernate SessionFactory().getCurrentSession()猫腻
- Hibernate save 插入数据问题
- hibernate+mysql save数据到数据库乱码解决办法
- hibernate-save-插入数据库的方法
- Hibernate学习笔记——SessionFactory.getCurrentSession()
- Hibernate SessionFactory openSession vs getCurrentSession vs openStatelessSession
- hibernate中的SessionFactory的openSession与getCurrentSession
- 4.Hibernate首例:插入数据save
- SessionFactory.getCurrentSession()
- hibernate中的session.save无法保存数据
- struts+spring+hibernate无法插入数据库数据的问题
- 变压器资源整理帖
- i2c 驱动编程接口 i2c_master_send 和 i2c_master_recv i2c_transfer
- Spring+quartz集群配置,Spring定时任务集群,quartz定时任务集群
- 学习php的一个优秀网址
- 安卓Notification小总结
- hibernate调用sessionFactory.getCurrentSession().save(entity);数据无法插入到数据库
- Mybatis通过@调用javal 类的静态代码和常量
- iOS自定义控件一
- Android万能的图片加载框架(Glide、Fresco、Picasso)
- 1080p
- Android具有粘性的小球,跌落反弹形成文字的动画效果
- 水平分库分表的关键步骤和技术难点
- 搭建项目的MySql问题 table不存在的问题
- Shell中的${}、##和%%使用范例