Results 1 to 4 of 4

Thread: spring rollback when error

  1. #1

    Default spring rollback when error

    Hi,

    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.
    Clément

  2. #2
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    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.

  3. #3

    Default

    Yes, its ok for me.
    I misunderstood transactions and propagation, and I made mistakes in my code.
    thanks

  4. #4
    Join Date
    Apr 2011
    Location
    Delhi
    Posts
    1

    Default Reply

    Yes I can understand this....
    ---------------------------
    Consumer Court,India Price

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •