Heim  >  Artikel  >  Datenbank  >  【文档摘要】J2EE Persistence

【文档摘要】J2EE Persistence

WBOY
WBOYOriginal
2016-06-07 15:50:06949Durchsuche

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 attr

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn