- 浏览: 7952 次
- 性别:
- 来自: 江西
最新评论
-
t_tianxingjian:
你好,我在使用事务代理的时候测试没生效。帮忙看看哪里有问题。谢 ...
TransactionProxyFactoryBean代理事务
文章列表
web.xml
<?xml version="1.0" encoding="GBK"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/w ...
- 2009-09-18 21:51
- 浏览 726
- 评论(0)
配置文件:
<?xml version="1.0" encoding="GBK"?>
<!-- 指定Spring配置文件的Schema信息 -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema ...
- 2009-09-18 20:04
- 浏览 947
- 评论(0)
配置文件:
<?xml version="1.0" encoding="GBK"?>
<!-- 指定Spring配置文件的DTD信息 -->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!-- Spring配置文件的根元素 -->
<beans>
<!-- ...
- 2009-09-18 19:58
- 浏览 3781
- 评论(1)
采用声明式事务
1、声明式事务配置
* 配置SessionFactory
* 配置事务管理器
* 事务的传播特性
* 那些类那些方法使用事务
2、编写业务逻辑方法
* 继承HibernateDaoSupport类,使用HibernateTemplate来持久化,HibernateTemplate是
Hibernate Session的轻量级封装
* 默认情况下运行期异常才会回滚(包括继承了RuntimeException子类),普通异常是不会滚的
* 编写业务逻辑方法时,最好将异常一直向上抛出,在表示层(struts)处理
* 关于事务边界的设置,通常设置到业务层,不要 ...
- 2009-09-17 00:26
- 浏览 1048
- 评论(0)
采用编程式事务
1、getCurrentSession()与openSession()的区别?
* 采用getCurrentSession()创建的session会绑定到当前线程中,而采用openSession()
创建的session则不会
* 采用getCurrentSession()创建的session在commit或rollback时会自动关闭,而采用openSession()
创建的session必须手动关闭
2、使用getCurrentSession()需要在hibernate.cfg.xml文件中加入如下配置:
* 如果使用的是本地事务(jdbc事务)
...
AOP术语:
* Cross cutting concern
* Aspect
* Advice
* Pointcut
* Joinpoint
* Weave
* Target Object
* Proxy
* Introduction
AOP实例:
定义切面:
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
/**
* 定义Aspect
* @ ...
- 2009-09-16 17:27
- 浏览 706
- 评论(0)