[html]
< xml version="1.0" encoding="UTF-8" >
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"
default-lazy-init="false">
这就是一个spring的事务管理,aop切到的方法都将具备事务的特性。
注意:使用事务必需提供一个SessionFactory这是毋庸置疑的,但使用hibernate事务时一般将Session绑定到线程,只需设置:hibernate.current_session_context_class=thread,
而使用spring 的事务时,就不是将Session绑定到线程了,而是将Session绑定的spring的一个管理Session的容器中,设置wei :hibernate.current_session_context_class=org.springframework.orm.hibernate3.SpringSessionContext,
如果没有使用事务对应的Seesion绑定设置,程序就会报错~,因为如果是 启用spring事务时,那么spring就会向SpringSessionContext要Session,如果Session没有绑定到SpringSessionContext类中,结果可想而知了。
作者:vean_system