CHAPTER 10 Transactions and concurrency An application, by (Web hosting isp)

CHAPTER 10 Transactions and concurrency An application, by definition, always executes a planned sequence of statements. It seems reasonable that you therefore always create transaction boundaries to group your statements into units that are atomic. Therefore, the autocommit mode has no place in an application. 10.3.1 Debunking autocommit myths Many developers still like to work with an autocommit mode, often for reasons that are vague and not well defined. Let s first debunk a few of these reasons before we show you how to access data nontransactionally if you want (or have) to: Many application developers think they can talk to a database outside of a transaction. This obviously isn t possible; no SQL statement can be send to a database outside of a database transaction. The term nontransactional data access means there are no explicit transaction boundaries, no system transaction, and that the behavior of data access is that of the autocommit mode. It doesn t mean no physical database transactions are involved. If your goal is to improve performance of your application by using the autocommit mode, you should think again about the implications of many small transactions. Significant overhead is involved in starting and ending a database transaction for every SQL statement, and it may decrease the performance of your application. If your goal is to improve the scalability of your application with the auto- commit mode, think again: A longer-running database transaction, instead of many small transactions for every SQL statement, may hold database locks for a longer time and probably won t scale as well. However, thanks to the Hibernate persistence context and write-behind of DML, all write locks in the database are already held for a short time. Depending on the isolation level you enable, the cost of read locks is likely negligible. Or, you may use a DBMS with multiversion concurrency that doesn t require read locks (Oracle, PostgreSQL, Informix, Firebird), because readers are never blocked by default. Because you re working nontransactionally, not only do you give up any transactional atomicity of a group of SQL statements, but you also have weaker isolation guarantees if data is modified concurrently. Repeatable reads based on read locks are impossible with autocommit mode. (The persistence context cache helps here, naturally.)
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Leave a Reply