Transaction Attribute

2. Spring Framework support, for property

1) PROPAGATION_REQUIRED - to support the current transaction, if does not exist to create a new one. This is the most common choice.
2) PROPAGATION_SUPPORTS - to support the current transaction, if there is no use of services.
3) PROPAGATION_MANDATORY - to support the current transaction, if does not exist throw an exception.
4) PROPAGATION_REQUIRES_NEW - to create a new transaction, and suspend the current transaction (if it exists).
5) PROPAGATION_NOT_SUPPORTED - do not use services, and suspend the current transaction (if it exists).
6) PROPAGATION_NEVER - do not use matters, if the current transaction will throw an exception exists.
7) PROPAGATION_NESTED - if the current exists, as embedded in matters regarding the implementation of transaction, or with PROPAGATION_REQUIRED similar.

3. Attention

1) PROPAGATION_REQUIRES_NEW and PROPAGATION_NESTED

PROPAGATION_REQUIRES_NEW start a new, does not depend on the environment of the "internal" affairs. This transaction will be fully commited or rolled back instead of relying on external affairs, the scope of its own isolation, their locks, and so on. When the internal affairs of the beginning executed, the external affairs will be suspended, the House Affairs, at the end of the external affairs will continue.

On the other hand, PROPAGATION_NESTED start a "nested" transaction, which is already existing services a real child transaction. Sets of potential transaction started, it will get a savepoint. If the nested transaction fails, we will roll back to this savepoint. submarine sets affairs are part of external affairs, only the external affairs after the end of it will be presented. Savepoint need the latest JDBC specification to support. JDBC3?

Thus, PROPAGATION_REQUIRES_NEW and PROPAGATION_NESTED the biggest difference is that, PROPAGATION_REQUIRES_NEW is a completely new transaction, while the PROPAGATION_NESTED is the External Affairs sub-transaction, if the external affairs commit, nested transaction will also be commit, this rule also applies to roll back .

2) Required and mandatory transaction attribute

Two kinds of support transaction context. If you call when there is no difference between the transaction context, Required to be launching a new business. The mandatory exception to be thrown.

Deep-seated differences based on the following rules:

With the exception of the stateful session bean, the method that starts a transaction must be the same method that terminates the transaction.

Required services can not be sure whether it is because in this method to start or come in from outside the pass, and therefore do not know whether to do this treatment rollback when an exception occurs. The Mandatory to confirm matters are imported from the outside, so know they do not need to deal with this logic.

分类:Java 时间:2009-05-06 人气:261
分享到:
blog comments powered by Disqus

相关文章

  • (Reprinted little assembly) Spring Framework Introduction 2 - When Spring Hibernate event 2010-06-01

    http://www.ibm.com/developerworks/cn/java/wa-spring2/index.html Naveen Balani continues his Spring series, introduced the Hibernate transaction with Spring aspect-oriented programming (AOP) integration of knowledge. The result is a persistence framew

  • [Change] using Spring and Apache CXF POJO Web services design and implementation, Part 1: Using CXF and Spring Create Web Services 2010-03-31

    September 18, 2008 Using the open source Apache CXF Web Services Framework can easily create traditional Java ™ objects (plain old Java object, POJO)-style Web services. This article is Part 1 of this series, will show you how to use Spring and CXF P

  • Spring Framework's design concept and design patterns (7)-Spring AOP features and implementation in 2010-08-31

    Keywords: Spring, AOP, Proxy, proxy, blocker the last chapter: Spring Framework's design concept and design patterns (6)-Ioc container and BeanFactory factory http://javapub.javaeye.com/blog/751635 Next Chapter: Spring Framework's design concept and

  • Spring Study Notes: Spring Framework Overview 2010-03-29

    ◆ Introduction Objective: To solve the complexity of enterprise application development Function: Using the basic JavaBean to replace EJB, and provides additional functionality of enterprise applications Range: Any Java Application Spring Framework i

  • Spring Study Notes: Spring Framework Overview switch 2010-03-29

    http://www.javaeye.com/topic/583213 ◆ Introduction Objective: To solve the complexity of enterprise application development features: the use of basic JavaBean to replace EJB, and provides a more functional scope of enterprise applications: Any Java

  • Spring Framework's main function 2010-06-11

    Spring Framework Spring framework composed of the main functions of each module (or component) can stand alone, or with other joint realization of one or more modules. Each module functions as follows: Core container: Spring core container provides t

  • Spring Framework Overview 2010-07-05

    Spring Framework contains a number of features, and is well organized in the next chart shows the six modules. This section describes each module in turn. Core package package is the most basic part of the framework, providing IoC and dependency inje

  • Detailed Analysis of Spring framework 2010-03-29

    In this three-part introduction to Spring framework of a series of articles in the first period, Spring will start learning how to use technology to build lightweight, robust J2EE applications. Regular developerWorks contributor Naveen Balani introdu

  • (Reprinted little assembly) Spring Framework Introduction 2010-06-01

    http://www.ibm.com/developerworks/cn/java/wa-spring1/ Author: Naveen Balani (naveenbalani@rediffmail.com), technical architect, Webify Solutions In this three-part introduction to Spring framework of a series of articles in the first period, will beg

  • Summary of Struts, Hibernate, Spring Framework 2010-09-29

    Summary of Struts, Hibernate, Spring Framework Hibernate Works and why to use ? Principle : 1. Read and parse the configuration file 2. Read and parse the mapping information, create SessionFactory 3. Open Sesssion 4. Create Service Transation 5. Per

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.272 (s). 12 q(s)