InfoQ: Eight Isolation Levels Every Web Developer Should Know
Eight Isolation Levels Every Web Developer Should Know
InfoQ: Eight Isolation Levels Every Web Developer Should Know
Eight Isolation Levels Every Web Developer Should Know
JPA 2.0 Concurrency and locking | Java.net
JPA 2.0 Concurrency and locking
Java Persistence/Locking – Wikibooks, collection of open-content textbooks
Java Persistence/Locking
INSERT失败,因为下列SET选项的设置不正确: ‘ARITHABORT’? MS-SQL Server / 基础类 – CSDN社区 community.csdn.net
在对数据进行保存时,提示错误信息
INSERT 失败,因为下列SET选项的设置不正确: ‘ARITHABORT’?用语句:exec sp_dboption ‘SG_Control’,’ARITHABORT’,’true’后解决
想问,问题出现的原因是什么,有没有其他解决办法
使用Java Persistence中的@Version來執行Optimistic Locking.
1. 在資料庫中加入一個欄位for version checking, 在Oracle 中有個rowid, 只要資料有修改, 這個rowid就會跟著改變, 除了SQL Base外, 我所知的在其它的資料庫沒有這個機制. 但Oracle的rowid不能修改.
ALTER TABLE my_table ADD version_id bigint default 0 ;
update my_table set version_id=0
2.在Entity Class內加入
import javax.persistence.Version;
….
….
@Version
@Column(name = “version_id")
private Long version;public Long getVersion() {
return version;
}public void setVersion(Long version) {
this.version = version;
}
如此一來, JPA從資料庫讀入時, 會把version_id讀進來, 在update時, 除了primary key外, 還會去判斷這個欄位是否和原來讀入的一樣, 如果不一樣, 就會發出exception, 不讓JPA寫到資料庫.
如果成功寫入的話, 則會自動的把這個欄位的值加一.
https://java.sun.com/javaee/5/docs/api/javax/persistence/Version.html
http://en.wikibooks.org/wiki/Java_Persistence
EJB 3.0 Persistence – using the @Version annotation for Optimistic Locking – in the GlassFish Reference Implementation by Lucas Jellema
Using TopLink JPA ExtensionsVersion: 05/01/2008
The Java Persistence API (JPA), part of the Java Enterprise Edition 5 (Java EE 5) EJB 3.0 specification, greatly simplifies Java persistence and provides an object-relational mapping approach that allows you to declaratively define how to map Java objects to relational database tables in a standard, portable way that works both inside a Java EE 5 application server and outside an EJB container in a Java Standard Edition (Java SE) 5 application.
TopLink JPA provides extensions to what is defined in the JPA specification. These extensions come in persistence unit properties, query hints, annotations, TopLink own XML metadata, and custom API. For more information on where and how you use the extensions to customize JPA behavior to meet your application requirements, see Oracle Fusion Middleware Developer’s Guide for Oracle TopLink.
TopLink JPA Extensions Reference
Example: persistence.xml fileExample: property Map
import oracle.toplink.essentials.config.TargetDatabase;
import oracle.toplink.essentials.config.TopLinkProperties;
propertiesMap.put(TopLinkProperties.TARGET_DATABASE, TargetDatabase.Oracle);
Chapter 9. Transactions
Identify correct and incorrect statements or examples about bean-managed transaction demarcation.
Java Persistence/Locking – Wikibooks, collection of open-content textbooks
Java Persistence/Locking
ALTER DATABASE hipergate20 SET ARITHABORT ON
hipergate :. Free Open Source CRM Groupware and Intranet Software
Microsoft SQL Server 2000