getHibernateTemplate().save ()成功但不能写入数据库 解决方法

来源:互联网 发布:python 流量 预测 编辑:程序博客网 时间:2024/05/02 00:50

数据被缓存了未flush。

save方法后添加getHibernateTemplate().flush();


在hibernate.cfg.xml里面加入 

 <property name="connection.autocommit">true </property>

如果用spring管理Hibernate,则applicationContext.xml中

<property name="hibernateProperties">
<props>

<prop key="connection.autocommit">true</prop> <!-- 添加这个 -->

<props>

</property>


原创粉丝点击