Spring affairs readonly

Source: https: //www.cnblogs.com/straybirds/p/9147892.html

Spring's transaction often have this configuration:

<tx:method name="search*" read-only="true" /> 

Or such Notes:

@Transactional(readOnly = true)

the reason:

"Read-only transaction" is not a mandatory option, it's just a "hint", suggesting that the database drivers and database systems, this transaction does not include changes to the operation of the data, 
then the JDBC driver and database according to this situation is likely to the transaction some specific optimizations,
for example say no to arrange the appropriate database lock, to relieve the pressure on the database of the transaction, after the transaction is to consume resources database.
Readonl 1 the y-not all databases support, there will be different results under different database. 
After 2 provided readonly, Connection will be given readonly, the effect depending on the implementation of the database. 
3 in ORM, set the readonly would give some additional optimizations, such as Hibernate, is prohibited flush and so on.

Guess you like

Origin www.cnblogs.com/cn-chy-com/p/11281766.html