【文档摘要】J2EE Persistence - Controlling Concurrent Access to Entity Data with Locking
2014-11-24 21:20
633 查看
short term read lock / long term write lock
Optimistic Locking: version column
Pessimistic Locking: create a transaction to obtain long term lock
Lock Modes:
OPTIMISTIC: Obtain an optimistic read lock for all entities with version attributes.
OPTIMISTIC_FORCE_INCREMENT: Obtain an optimistic read lock for all entities with version attributes, andincrement the version attribute value.
READ: OPTIMISTIC.
WRITE: OPTIMISTIC_FORCE_INCREMENT.
PESSIMISTIC_READ: immediately obtain a long-term read lock on the data toprevent the data being
modified or deleted. Other transactions may read the data while the lock is maintained, but not modify or delete the data.
PESSIMISTIC_WRITE: immediately obtain a long-term write lock on the data toprevent the data being
read, modified ordeleted.
PESSIMISTIC_FORCE_INCREMENT: immediately obtain a long-term lock on the data toprevent the data being
modified or deleted, and increment the version attribute value.
NONE: no additional locking.
Question:
How to choose which mode to use????
参考资料:
https://docs.oracle.com/javaee/7/tutorial/doc/persistence-locking001.htm#GKJHZ
https://blogs.oracle.com/carolmcdonald/entry/jpa_2_0_concurrency_and
Optimistic Locking: version column
Pessimistic Locking: create a transaction to obtain long term lock
Lock Modes:
OPTIMISTIC: Obtain an optimistic read lock for all entities with version attributes.
OPTIMISTIC_FORCE_INCREMENT: Obtain an optimistic read lock for all entities with version attributes, andincrement the version attribute value.
READ: OPTIMISTIC.
WRITE: OPTIMISTIC_FORCE_INCREMENT.
PESSIMISTIC_READ: immediately obtain a long-term read lock on the data toprevent the data being
modified or deleted. Other transactions may read the data while the lock is maintained, but not modify or delete the data.
PESSIMISTIC_WRITE: immediately obtain a long-term write lock on the data toprevent the data being
read, modified ordeleted.
PESSIMISTIC_FORCE_INCREMENT: immediately obtain a long-term lock on the data toprevent the data being
modified or deleted, and increment the version attribute value.
NONE: no additional locking.
Question:
How to choose which mode to use????
参考资料:
https://docs.oracle.com/javaee/7/tutorial/doc/persistence-locking001.htm#GKJHZ
https://blogs.oracle.com/carolmcdonald/entry/jpa_2_0_concurrency_and
相关文章推荐
- 【文档摘要】J2EE Persistence - Introduction to the Java Persistence API【Managing Entities】
- 【文档摘要】J2EE Persistence - Introduction to the Java Persistence API【Entities】
- 【文档摘要】J2EE Persistence - Introduction to the Java Persistence API【Entities Inheritance】
- 【文档摘要】J2EE Persistence - Introduction to the Java Persistence API【Querying Entities】
- [JPA] javax.persistence.EntityNotFoundException: Unable to find XXXX with id 0 问题原因
- [JPA] javax.persistence.EntityNotFoundException: Unable to find XXXX with id 0
- SPRING IN ACTION 第4版笔记-第十一章Persisting data with object-relational mapping-002设置JPA的EntityManagerFactory(<persistence-unit>、<jee:jndi-lookup>)
- user master page with asp:FormParameter , save only blank data to Database MSAccess
- Hawq学习笔记 --- How to access HDFS data via GPDB external table with gphdfs protocol
- [JPA] javax.persistence.EntityNotFoundException: Unable to find com.duona.base.bean.Business with id
- Python for Everybody-Using Python to Access Web DatExtracting Data With Regular Expressions
- [JPA] javax.persistence.EntityNotFoundException: Unable to find XXXX with id 0 问题原因
- 【翻译】Data Access with LINQ to SQL (1) -- New C# and VB.NET Language Features
- user master page with asp:FormParameter , save only blank data to Database MSAccess
- Using ROW_NUMBER() to paginate your data with SQL Server 2005 and ASP.NET
- A Data Access Layer to persist business objects using attributes and reflection - Part I [无常译]
- A Data Access Layer to persist business objects using attributes and reflection - Part I
- Implement a Data Access Layer for Your App with ADO.NET
- 10 Things You Shouldn't Do with SQL Server (Data Access Developer "Don'ts")
- A Data Access Layer to persist business objects using attributes and reflection - Part III