日期:2014-05-16  浏览次数:20565 次

getHibernateTemplate().save不写入数据库的解决
今天发现一个问题 getHibernateTemplate().save不写入数据库,但是发现sql语句已经在控制台打印出来了。 getHibernateTemplate().flush();也没有作用


最后估计是在缓存中没有提交。


解决办法:<property name="connection.autocommit">true</property>


更好的解决办法:在事务配置里:
<property name="transactionAttributes">
<props>
<prop key="saverr">PROPAGATION_REQUIRED</prop>

</props>
</property>

把对应的方法 设置为PROPAGATION_REQUIRED