READ: From this point of time set the point of Start (Point a) to the end of this transaction, other transactions submitted data, the transaction will not be visible. (No data submitted by others after point A in the query)
Application occasions:
If you execute a single query statement at a time, it is not necessary to enable transaction support, and the database defaults to support read consistency during SQL execution;
If you execute more than one query at a time, such as a statistical query, report query, in this scenario, multiple query SQL must ensure the overall read consistency, otherwise, after the previous SQL query, after the SQL query, the data was changed by other users, then the overall statistical query will appear reading data inconsistent state, At this point, transaction support should be enabled.
"Note that multiple queries are executed at a time to count certain information, and in order to ensure the overall consistency of the data, read-only transactions are used"
How to set up:
For read-only queries, you can specify that the transaction type is ReadOnly, that is, a read-only transaction.
Because a read-only transaction does not have modifications to the data, the database provides some optimizations for read-only transactions, such as Oracle for read-only transactions, does not start rollback segments, and does not log rollback log.
(1) in JDBC, the method for specifying read-only transactions is: Connection.setreadonly (true);
(2) in Hibernate, the method for specifying read-only transactions is: Session.setflushmode (flushmode.never);
At this point, hibernate also provides some optimizations for the session for read-only transactions
(3) In spring's hibernate package, the method for specifying read-only transactions is: In the bean configuration file, the Prop attribute increases "readOnly"
or @transactional (readonly=true) in annotation mode
"If" transaction is marked as Read-only, Spring'll set the Hibernate session ' s flush mode to Flush_never,
And would set the JDBC transaction to Read-only "that is, setting up read-only transactions in spring is the use of the above two ways
When a transaction is set to read-only, the equivalent of setting the database to a read-only database, an error occurs when a write operation is made