• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data commiited even after readonly=true, please help!!

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am currently developing a Spring MVC application.I have configured a JDBC TransactionManager and I am doing declarative transaction management using AOP XML.However, even if I configure the method to run on a read-only=true, it still commits the transaction.

Database : Oracle 10g

My database-config.xml




My controller



How do I prevent the auto commit? I have also noticed that even if I don't put any transaction management code, the code still commits. Please help. Note, the transaction advice is however,invoked as when I put a no-rollback-for for RuntimeException and then do a 1/0, it correctly commits the data and rolls back if I put the same as rollback-for.
I have also tried out the query timeout by putting the thread on sleep, even that doesn't work, but I figure that timeout might be for an actual query, so thats fine.
Please help!!
 
Anirban Chowdhury
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer is on http://forum.springsource.org/showthread.php?126145-Data-commiited-even-after-readonly-true-please-help!!&p=411771&posted=1#post411771

Detailed stack traces are also available. To summarize,

1.Read-only is only an advice and it guarantees nothing, and I would really like the Spring docs to be updated about this.
2.Whenever a query is executed in Oracle using Mybatis, it is in the context of a transaction which is automatically started, committed(or rolled back, if execption is raised),and closed by Mybatis.
3.Logging the application is a good idea and it helped me to find out how the actual transactions are started etc.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anirban is correct but I just wanted to point out that the spring docs are clear about this:

public abstract boolean readOnly

true if the transaction is read-only. Defaults to false.

This just serves as a hint for the actual transaction subsystem; it will not necessarily cause failure of write access attempts. A transaction manager which cannot interpret the read-only hint will not throw an exception when asked for a read-only transaction.



It is still worth having as optimizations maybe made by the persistence provider or Spring based on this.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic