Apr 2nd, 2011, 07:34 AM
spring rollback when error
I am using AOP to manage my transactions with @Transactional on my services. And that works very well when a runtime exception occurs a rollback is performed. (I use hibernate and spring manage my hibernate layer)
But sometimes a java.lang.outOfMemoryError occurs during the transaction (caused by my own bad management of memory), then Spring can't call rollback and data stay persisted.
do you know a solution to prevent this ?
I supposed that the transaction use "BEGIN TRANSACTION... sql code...COMMIT" for the transaction of my method, but i don't how it is possible to maintains transaction if I have nested transaction. I am investigating on that.
Thank you for your help.
Apr 4th, 2011, 02:41 AM
How transactionality internally works very much depends on how you configure your transaction manager. Simply put, @Transactional only uses Spring AOP to "wrap" code inside a transaction start / commit / rollback; how that transaction is managed depends on the transaction manager you configure, and also on the underlying persistence system (in your case, Hibernate) and your database (different databases have different ways to manage transactions and also offer different "standard" behaviours).
I suggest you start your investigation by studying the transaction manager you are using (especially how it interacts with the Hibernate framework) and the specs of transaction management of your dbms. Also, take a look at the propagation settings for @Transactional as that can be the key to solve your problem.
Apr 5th, 2011, 10:15 AM
Yes, its ok for me.
I misunderstood transactions and propagation, and I made mistakes in my code.
Apr 6th, 2011, 06:37 AM
Yes I can understand this....
Consumer Court,India Price
Tags for this Thread