Read-Only transactions

read-only="true|false" 经常出现在Spring事务配置文件或者annotation 属性中,具体解释如下:

 

 

1. Spring documents describes:

 

Read-only status: a read-only transaction does not modify any data. Read-only transactions can be a useful optimization in some cases (such as when using Hibernate).

2. from Google

 

if the transaction is marked as read-only, Spring will set the Hibernate Session's flush mode to FLUSH_NEVER, and will set the JDBC transaction to read-only.

 

3. Hiberante

 

when a session's flush mode is set to FLUSH_NEVER, two things happen:

First, running HQL queries no longer cause Hibernate to flush the session state to the database, which can provide a dramatic performance improvement.

Secondly, Hibernate will not flush the changes before commiting the transaction. But the user can still call Session.flush() by hand, causing any modifications to be persisted to database.

 

4. Oracle

 

When using the Oracle JDBC driver, calling connection.setReadOnly(true) translates into the statement "SET TRANSACTION READ ONLY". This statement limits the types of SQL statements that can be executed during the transaction. Only SELECTS (without 'FOR UPDATE') and a few other statements can be executed. Specifically, no UPDATEs, DELETEs, INSERTs or MERGEs can be executed. This behavior is Oracle-specific. Other RDBMS can have different semantics for read only transactions or simply not support it at all.

 

 

 

from:  http://www.codeinstructions.com/2009/04/read-only-transactions-with-spring-and.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值