`
Wingel
  • 浏览: 117612 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

transaction in Spring

阅读更多

Propagation behavior:

PROPAGATION_MANDATORY:
 Indicates that the method must run within a transaction. If no
 existing transaction is in progress, an exception will be thrown.


PROPAGATION_NESTED:
 Indicates that the method should be run within a nested transaction
 if an existing transaction is in progress. The nested transaction
 can be committed and rolled back individually from the enclosing
 transaction. If no enclosing transaction exists, behaves like
PROPAGATION_REQUIRED:
 Beware that vendor support for this propagation behavior is spotty at best.
 Consult the documentation for your resource  manager to determine if nested
 transactions are supported.
PROPAGATION_NEVER:
 Indicates that the current method should not run within a transactional
 context. If there is an existing transaction in progress, an
 exception will be thrown.
PROPAGATION_NOT_SUPPORTED:
 Indicates that the method should not run within a transaction. If an
 existing transaction is in progress, it will be suspended for the
 duration of the method. If using JTATransactionManager,
 access to TransactionManager is required.
PROPAGATION_REQUIRED:
 Indicates that the current method must run within a transaction. If
 an existing transaction is in progress, the method will run within
 that transaction. Otherwise, a new transaction will be started.
PROPAGATION_REQUIRES_NEW:
 Indicates that the current method must run within its own transaction.
 A new transaction is started and if an existing transaction is in
 progress, it will be suspended for the duration of the method. If
 using JTATransactionManager, access to Transaction-
 Manager is required.
PROPAGATION_SUPPORTS:
 Indicates that the current method does not require a transactional
 context, but may run within a transaction if one is already in
 progress.


Isolation levels:
In a typical application, multiple transactions run concurrently, often working
with the same data to get their job done. Concurrency, while necessary, can lead
to the following problems:
 ■ Dirty read—Dirty reads occur when one transaction reads data that has
 been written but not yet committed by another transaction. If the
 changes are later rolled back, the data obtained by the first transaction
 will be invalid.
 ■ Nonrepeatable read—Nonrepeatable reads happen when a transaction performs
 the same query two or more times and each time the data is different.
 This is usually due to another concurrent transaction updating the
 data between the queries.
 ■ Phantom reads—Phantom reads are similar to nonrepeatable reads. These
 occur when a transaction (T1) reads several rows, then a concurrent transaction
 (T2) inserts rows. Upon subsequent queries, the first transaction
 (T1) finds additional rows that were not there before.


Isolation level:
ISOLATION_DEFAULT:
 Use the default isolation level of the underlying datastore.
ISOLATION_READ_UNCOMMITTED:
 Allows you to read changes that have not yet been committed. May
 result in dirty reads, phantom reads, and nonrepeatable reads.
ISOLATION_READ_COMMITTED:
 Allows reads from concurrent transactions that have been committed.
 Dirty reads are prevented, but phantom and nonrepeatable
 reads may still occur.
ISOLATION_REPEATABLE_READ:
 Multiple reads of the same field will yield the same results, unless
 changed by the transaction itself. Dirty reads and nonrepeatable
 reads are prevented by phantom reads may still occur.
ISOLATION_SERIALIZABLE:
 This fully ACID-compliant isolation level ensures that dirty reads,
 nonrepeatable reads, and phantom reads are all prevented. This is
 the slowest of all isolation levels because it is typically accomplished
 by doing full table locks on the tables involved in the transaction. 



分享到:
评论

相关推荐

    Implementing Transaction Suspension in Spring

    本篇文章将深入探讨Spring的事务管理机制,特别是如何实现事务的挂起(Transaction Suspension),并展示如何利用Spring的声明式事务管理来处理POJO(Plain Old Java Object)对象,同时使用JTA(Java Transaction ...

    org.springframework.transaction-3.1.2.RELEASE.zip

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionInterceptor#0': Error setting property values; nested ...

    Spring in action 2nd

    ### Spring in Action 第二版 —— 详尽解析与学习指南 #### 一、书籍概述 《Spring in Action》第二版是一本深受开发者喜爱的技术书籍,由Craig Walls和Ryan Breidenbach共同撰写,并由Manning出版社出版。这本书...

    Spring 实践(Spring in Practice).pdf版本

    In this respect, Spring is like JEE and even its earlier J2EE incarnation. Spring’s approach—based on POJOs, dependency injection, and support for a wide variety of third-party libraries—proved to...

    Spring Batch in Action

    《Spring Batch in Action》是一本深入探讨Spring Batch框架的书籍,由Arnaud Cogoluègnes、Thierry Templier、Gary Gregory和Olivier Bazoud共同编写,Manning出版社出版。这本书旨在帮助读者理解和掌握如何使用...

    spring in action 示例源码

    《Spring in Action》是一本非常经典的Spring框架实战书籍,它以丰富的示例代码和详细的解释,帮助读者深入理解和掌握Spring框架的各种功能。源码是学习过程中极好的参考资料,能够直观地展示理论在实际项目中的应用...

    Spring_in_Action.pdf

    Spring框架的核心功能包括依赖注入(Dependency Injection,DI)、面向切面编程(Aspect-Oriented Programming,AOP)、数据访问/集成(Data Access/Integration)、事务管理(Transaction Management)、模型-视图-...

    Getting.started.with.Spring.Framework.2nd.Edition1491011912.epub

    All the examples shown in this book use Spring 4. You can download the examples (consisting of 60 sample projects) described in this book from the following Google Code project: code.google....

    Pro Spring 3

    How to build transaction engines for your enterprise application and take advantage of other middle-tier features in Spring How to build Spring-based web applications using Spring MVC and more How to ...

    spring in action中文版

    《Spring in Action》是一本深度剖析Spring框架的权威著作,中文版的出版使得更多的中国开发者能够轻松理解并掌握Spring的核心概念和技术。这本书以其详尽的解释、丰富的实例和清晰的结构,深受Java开发者喜爱。主要...

    Spring.Essentials.178398

    Explore Spring's comprehensive transaction support for declarative Transaction Management and its integration with Spring's data access abstractions Investigate Spring Data access mechanisms with ...

    AspectJ in Action: Enterprise AOP with Spring Applications

    ### AspectJ in Action: Enterprise AOP with Spring Applications #### 关键知识点概述 1. **Spring-AspectJ集成:**本书重点介绍了Spring框架与AspectJ相结合的技术优势及其在企业级应用中的强大功能。 2. **...

    springbatch 详解PDF附加 全书源码 压缩包

    4. **Transaction Management**: 研究源码,学习 Spring Batch 如何进行事务管理,确保数据一致性。 5. **Retry and Skip Logic**: 探索如何在代码中实现重试和跳过错误的逻辑。 **四、Spring Batch 实战应用** 1....

    Spring in Action(英文版)

    Spring 框架的核心特性包括依赖注入(Dependency Injection, DI)、面向切面编程(Aspect-Oriented Programming, AOP)、数据访问/集成(Data Access / Integration)、事务管理(Transaction Management)、模型-...

    Spring in Action(英文版)

    3. **事务管理(Transaction Management)**:Spring提供了强大的事务管理功能,可以处理不同数据源的事务。无论是编程式事务管理还是声明式事务管理,Spring都提供了简便的API和注解,使得事务管理变得简单易行。 4....

    Spring-Reference_zh_CN(Spring中文参考手册)

    2. Spring 2.0 的新特性 2.1. 简介 2.2. 控制反转(IoC)容器 2.2.1. 更简单的XML配置 2.2.2. 新的bean作用域 2.2.3. 可扩展的XML编写 2.3. 面向切面编程(AOP) 2.3.1. 更加简单的AOP XML配置 2.3.2. 对@AspectJ 切面的...

    springboot报错:NoClassDefFoundError: org/springframework/transaction/ReactiveTransactionManager

    springboot启动报错:java.lang.NoClassDefFoundError: org/springframework/transaction/ReactiveTransactionManager 不添加org.springframework.boot:spring-boot-starter-data-jpa:2.2.5.RELEASE,只有org....

    pro Spring

    Learn how to replace common EJB features with Spring alternatives, including Spring's comprehensive AOP-based transaction management framework. Learn to integrate and use these other open source ...

Global site tag (gtag.js) - Google Analytics