`
Wingel
  • 浏览: 114912 次
  • 性别: 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

    Implementing Transaction Suspension in Spring

    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...

    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....

    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 ...

    Distributed transactions in Spring, with and without XA

    Distributed transactions in Spring, with and without XA

    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.Persistence.with.Hibernate.2nd.Edition.1484202694

    How to use Spring Persistence, including using persistence tools in Spring as well as choosing the best Java persistence frameworks outside of Spring How to work with Spring Framework features such as...

    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 ...

    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 ...

    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....

    Spring.Cookbook.1783985801.epub

    Use the latest configuration style and web improvements in Spring 4 to write optimized code Build full-featured web applications such as Spring MVC applications efficiently that will get you up and ...

    Spring MVC 入门实例

    如果你手上有一本《Spring in Action》, 那么你最好从第三部分"Spring 在 Web 层的应用--建立 Web 层"开始看, 否则那将是一场恶梦! 首先, 我需要在你心里建立起 Spring MVC 的基本概念. 基于 Spring 的 Web 应用...

    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 切面的...

    spring-framework-reference 4.3.8.RELEASE

    Framework supports declarative transaction management, remote access to your logic through RMI or web services, and various options for persisting your data. It offers a full-featured MVC framework, ...

    spring-boot-reference.pdf

    Exposing YAML as Properties in the Spring Environment 24.6.3. Multi-profile YAML Documents 24.6.4. YAML Shortcomings 24.7. Type-safe Configuration Properties 24.7.1. Third-party Configuration 24.7.2....

    Spring中文帮助文档

    在IN语句中传入一组参数值 11.7.4. 处理复杂类型的存储过程调用 12. 使用ORM工具进行数据访问 12.1. 简介 12.2. Hibernate 12.2.1. 资源管理 12.2.2. 在Spring容器中创建 SessionFactory 12.2.3. The ...

    Spring API

    在IN语句中传入一组参数值 11.7.4. 处理复杂类型的存储过程调用 12. 使用ORM工具进行数据访问 12.1. 简介 12.2. Hibernate 12.2.1. 资源管理 12.2.2. 在Spring容器中创建 SessionFactory 12.2.3. The ...

    spring chm文档

    Spring Framework 开发参考手册 Rod Johnson Juergen Hoeller Alef Arendsen Colin Sampaleanu Rob Harrop Thomas Risberg Darren Davison Dmitriy Kopylenko Mark Pollack Thierry Templier Erwin ...

    spring ldap

    In addition to this, Spring LDAP provides transaction support, a pooling library, an Object-Directory Mapping (ODM) framework, an LDIF parsing library with Spring Batch integration, exception ...

    Learning Spring 5.0

    Beginning with an introduction to Spring and setting up the environment, the book will teach you in detail about the Bean life cycle and help you discover the power of wiring for dependency injection....

Global site tag (gtag.js) - Google Analytics