Announcement Announcement Module
Collapse
No announcement yet.
spring rollback when error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


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

      Comment


      • #4
        Reply

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

        Comment

        Working...
        X