设为首页 加入收藏

TOP

Spring事务配置的五种方式 (二)
2014-11-24 09:49:25 】 浏览:1742
Tags:Spring 事务 配置 方式
.springframework.org/schema/aop/spring-aop-2.5.xsd">

class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">



class="org.springframework.orm.hibernate3.HibernateTransactionManager">



class="org.springframework.transaction.interceptor.TransactionInterceptor">




PROPAGATION_REQUIRED







*Dao




transactionInterceptor









第四种方式:使用tx标签配置的拦截器

< xml version="1.0" encoding="UTF-8" >
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">



class="org.springframework.orm.hibernate3.HibernateTransactionManager">








expression="execution(* com.bluesky.spring.dao.*.*(..))" />
pointcut-ref="interceptorPointCuts" />


第五种方式:全注解


< xml version="1.0" encoding="UTF-8" >
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">



class="org.springframework.orm.hibernate3.HibernateTransactionManager">




此时在DAO上需加上@Transactional注解,如下:

package com.bluesky.spring.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;

import com.bluesky.spring.domain.User;

@Transactional
@Co

首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇filter应用 下一篇 根据wsdl文件生成java代码

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目