Mar 3rd, 2009, 05:03 AM
DB driver that supports read-only transaction
Could someone tell me which DB and JDBC DB drivers support Spring's read-only transaction (conn.setReadOnly(true)?) if I use DataSourceTransactionManager?
I'm currently using MS SQL + JTurbo + IBatis, but the read-only transaction does not throw Exception when I do DB update.
Mar 5th, 2009, 03:04 AM
Could someone give me a hint?
Mar 5th, 2009, 05:46 PM
If you take a look at java.sql.Connection javadoc you can find that setting readonly is just a hint for a driver (due to optimization) that can be ignored (as Oracle does) by DB.
Do you need to prevent issuing DML by setting readOnly ?
Mar 5th, 2009, 09:20 PM
Mar 6th, 2009, 02:18 AM
It is not completely right since HibernateTransactionManager only sets session flush mode to never but in the same transaction you can still modify your data using jdbc.
Solution on your problem mainly depends how you access your db and pn which level you wanna to protect it. On oracle you have additional isolation level :"read only" that really fits your needs.
But i would need to think how to enable this using Spring.
On the other side maybe Ibatis has some kind of hook you can use. In hibernate you have Interceptor (http://www.hibernate.org/hib_docs/v3...terceptor.html). Its onPrepareStatement method process all sqls. The easiest would be to find similar hook in Ibatis.
In the end you can think of creating proxy around your datasource to retrieve connection that can prohibits DML within read only transactions.
Mar 8th, 2009, 07:15 AM