日期:2014-05-19  浏览次数:20657 次

getHibernateTemplate().update()数据更新不到数据库,也输不出Sql执行语句,但前台有显示修改结果?
我在调用getHibernateTemplate().update()方法进行数据时,数据更新成功后前台返回结果正确,但在数据库中数据没有显示。在网上查了之后再配置文件中加上<prop key="hibernate.connection.autocommit">true</prop>还是不行,但我在加上getSession.flush()方法后就可以了,但我想知道可否不加上getSession.flush()解决。
这是我的Spring配置文件:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.news.model.User</value>
<value>com.news.model.News</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="show_sql">true</prop>
<prop key="hbm2ddl.auto">create</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.connection.autocommit">true</prop>
</props>
</property>
</bean>
------最佳解决方案--------------------
可以 spring 代码中 设置 flush模式 什么的 好像
------其他解决方案--------------------
你Update的完整代码是?取得Connection有没有取消autocommit?
------其他解决方案--------------------
看看是否设置了自动提交!

引用:
你Update的完整代码是?取得Connection有没有取消autocommit?

------其他解决方案--------------------
把日志级别设为debug,看输出信息
不用template试试
------其他解决方案--------------------
有取消autocommit吗?
------其他解决方案--------------------
引用:
有取消autocommit吗?

没有取消,问题提了好久了,现在那个项目都弄好了。不过还是谢谢你。