好奇怪啊·~为什么我用spring+hibernate
修改数据库信息,数据库里的信息没变
但是却能查询到修改后的数据?只有重新载入服务器才能知道还是原来的数据 spring管理hibernate,不是可以自动管理事务
提交等等吗~~我在视频上看的 只要继承了hibernateDaoSupport
是不是我在spring 配置文件里少配置了什么东西 所以事务没有提交 ??
修改数据库信息,数据库里的信息没变
但是却能查询到修改后的数据?只有重新载入服务器才能知道还是原来的数据 spring管理hibernate,不是可以自动管理事务
提交等等吗~~我在视频上看的 只要继承了hibernateDaoSupport
是不是我在spring 配置文件里少配置了什么东西 所以事务没有提交 ??
解决方案 »
- JSP页面的刷新 tomcact
- WebSPhere与JaveEE是什么关系?
- common-logging和log4j一起使用,老是说找不到log4j配置文件
- 弱弱的问一下:用hibernate中的criteria怎么按月排序?
- 为什么我程序里的Session下面都出红线了
- AXIS配置问题
- 异常报错。在线等
- 用户请求为什么一定要给ActionServlet处理?
- CMP中要使用到Bean之间的关联关系只能用Local Interface?
- jcreator+j2sdk+jboss-3.2.1_tomcat-4.1.24?
- struts2导出PDF,文件字节是0.请高手帮忙指点指点
- 大哥大嫂们介绍下Spring AOP
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name="configLocation">
<value>WEB-INF/hibernate.cfg.xml</value>
</property>
</bean>
是不是要配置事务管理啊·~这是我的dao代码
public class StudentDao extends HibernateDaoSupport implements IStudentDao {
//添加学生
public void inputStu(Student student){
HibernateTemplate ht=this.getHibernateTemplate();
try {
ht.save(student);
ht.flush();
} catch (Exception e) {
e.printStackTrace();}
}
//添加学生
public void inputStu(Student student){ HibernateTemplate ht=this.getHibernateTemplate();
try {
ht.save(student);
ht.connection().commit();
ht.flush();
} catch (Exception e) { e.printStackTrace();}
}
参考:
<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" >
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 注册事务 -->
<tx:method name="save" propagation="REQUIRED"/>
<tx:method name="delete" propagation="REQUIRED"/>
<tx:method name="update" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice><!-- 哪些类的哪些方法参与事务 -->
<aop:config>
<aop:pointcut id="allDaoMethod" expression="execution(* org.wzc.exam.dao.*.*(..))"/>
<aop:advisor pointcut-ref="allDaoMethod" advice-ref="txAdvice"/>
</aop:config>
希望有所帮助……
另外有本myeclipse教程书,对jdk安装、tomcat部署、struts、spring、hibernate配置、整合介绍的尤其详细
有需要的朋友可以去看看
通过 HibernateDaosupport 能不能管理事务?
HibernateTemplate 在dao里 到底应该怎么用呢·~
通过 HibernateDaosupport 能不能管理事务?