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
本文详细介绍了Spring框架中如何利用read-only属性进行读写分离优化,包括其在Hibernate和Oracle等环境下的工作原理及性能提升策略。
552

被折叠的 条评论
为什么被折叠?



