Read-only transactions

Source: Internet
Author: User

Read-Only = "True | false" often appears in the Spring transaction configuration file or annotation attribute. The specific explanations are as follows:

 

 

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.